subra7978
9 years agoOccasional Contributor
Put Object to AWS S3 using multipart/form-data
I am trying to upload an image file to AWS S3 using HTTP PUT in a REST project. I have tried the following:
(1) Use a multipart attachment did not work because SoapUI inserted attachment headers which AWS inserted as part of the file. I read there was an option to disable multiparts, but could not find it.
(2) I used the following Groovy script to read the image into a single-byte string inserted the result of teh script into the payload of the request. This alsmost worked. But the iso-8859-1 encoding changed some bytes and corrupted the image.
import org.apache.commons.io.FileUtils; def filename = "path/to/file/name"; File file = new File(filename); def str = new String(file.readBytes()); return str;
Please help.