Skip to content

Commit d57dae0

Browse files
committed
1 parent 9f9d33b commit d57dae0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

grails-app/services/au/org/ala/merit/ImageService.groovy

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.drew.metadata.exif.GpsDirectory
99
import groovy.util.logging.Slf4j
1010
import groovyx.net.http.HttpResponseDecorator
1111
import grails.core.GrailsApplication
12+
import org.apache.http.HttpStatus
1213

1314
@Slf4j
1415
class ImageService {
@@ -23,14 +24,14 @@ class ImageService {
2324
* @return true if the thumbail was generated.
2425
*/
2526
boolean createThumbnail(InputStream imageIn, File thumbnailFile, String contentType, int size = 300) {
26-
Closure saveThumbnail = { HttpResponseDecorator resp, Object parsedData ->
27-
if (parsedData instanceof InputStream) {
28-
new FileOutputStream(thumbnailFile).withStream { it << parsedData }
27+
28+
Map resp = webService.postMultipart(grailsApplication.config.getProperty('ecodata.baseUrl') + "document/createThumbnail", [size: size], imageIn, contentType, thumbnailFile.name, 'image')
29+
if (resp.statusCode == HttpStatus.SC_OK) {
30+
def thumbnailData = resp.resp
31+
if (thumbnailData instanceof InputStream) {
32+
new FileOutputStream(thumbnailFile).withStream { it << thumbnailData }
2933
}
3034
}
31-
32-
webService.postMultipart(grailsApplication.config.getProperty('ecodata.baseUrl') + "document/createThumbnail", [size: size], imageIn, contentType, thumbnailFile.name, 'image', saveThumbnail)
33-
3435
return thumbnailFile.exists()
3536

3637
}

0 commit comments

Comments
 (0)