I have little js programm that uploads an image to my gcs bucket. If thi happens, my gcs sends a notification to a servlet at google app engine.
So far, so good. Now my servlet should read from gcs and download the file, which was uploaded a moment ago. Then i want to parse it into an image object and resize the image. The new image should be uploaded to another gcs bucket.
To communicate with gcs i use the gcs client lybrary.
GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
GcsFilename filename = new GcsFilename("bucket_name", "image_name");
GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(filename, 0, 1024 * 1024);
try ( ObjectInputStream inputStream = new ObjectInputStream(Channels.newInputStream(readChannel))){
inputStream.readObject();
log(inputStream.getClass().getName());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I also tried to save it in a byte array but the Error is always the same
Uncaught exception from servlet java.io.StreamCorruptedException: invalid stream header: FFD8FFE0
what am I doing wrong? Did I forget something? Thanks for your help.