I am working on an app that needs to upload pictures to Amazon. I am uploading like this:
s3Client.putObject( new PutObjectRequest(myBucket, myKey, myFile) );
Which works like a charm. The thing is that now I need to compress the picture before uploading it. I found this:
Bitmap original = BitmapFactory.decodeStream(...);
ByteArrayOutputStream out = new ByteArrayOutputStream();
original.compress(Bitmap.CompressFormat.JPEG, 100, out);
Bitmap compressed = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
That still needs to be tested though. So yeah, I could save the bitmap and use that new file to upload to Amazon, but I would have twice the same image in memory which is not required. I dont want to replace the original either if possible since I might want to use it later. I guess I could create a temporary file and delete it afterwards, but if there is a direct way to upload the bitmap variable, that would be great.
Thanks for any help