I want to save a image from my browser into google blobstore. What I already tried: Transform my img into a base64 string:
reader = new FileReader();
reader.readAsBinaryString(file);
call my Endpoint Function to send it to google app engine.
var request = gapi.client.helloworldendpoints.uploadImage({'imageData': __upload.imageData, 'fileName': __upload.fileName, 'mimeType': __upload.mimeType, 'size': __upload.size});
request.execute(
function (result) {
console.log("Callback:");
console.log(result);
}
);
My EndPoint in Java looks like this:
@ApiMethod(name = "uploadImage", path = "/uploadImage", httpMethod = "POST")
public ImageUploadRequest uploadImage(@Named("imageData") byte[] imageData, @Named("fileName") String fileName, @Named("mimeType") String mimeType, @Named("size") float size) {
return new ImageUploadRequest(imageData, fileName, mimeType, size);
}
The problem is, that my endpoint seems to be unable to handle the transfer of my base64. i always get 503 backend error
What would be the best way to send the data from my js client via app engine to blobstore?
UPDATE The main Problem is solved. I managed to upload the blob.
Javascript
var request = gapi.client.helloworldendpoints.uploadImage({
'imageData': __upload.imageData,
'fileName': __upload.fileName,
'mimeType': __upload.mimeType,
'size': __upload.size
});
Java Endpoint
public ImageUploadRequest uploadImage(
Request imageData,
@Named("fileName") String fileName,
@Named("mimeType") String mimeType,
@Named("size") float size
) { ... }
Request is just this
public class Request {
public Blob image;
}
My next Problem is the following How can i send a MultipartRequest from my Java Endpoint at GAE to my UploadServlet to create a blobkey and save the data into blobstorage, since Blobstorage only accepts data send to servlet?