setMD5Hash not working as expected

140 views
Skip to first unread message

Scott

unread,
Jul 15, 2010, 6:00:31 AM7/15/10
to JetS3t Users
I've been using this statement successfully to make sure uploaded
files are correctly uploaded:
s3Object.setMd5Hash(ServiceUtils.computeMD5Hash(byteArray));

Now I've had to change the byteArray to an inputStream. Great news is
that an overloaded computeMD5Hash accepts an inputStream:
s3Object.setMd5Hash(ServiceUtils.computeMD5Hash(inputStream));

the problem is when I use this mechanism and I call:
s3Service.putObject(fileBucket, s3Object);

then JetS3t hangs, eventually timing out. Do I need to reset the
inputStream after computing the MD5Hash? How is this supposed to work?

James Murty

unread,
Jul 15, 2010, 11:24:27 PM7/15/10
to jets3t...@googlegroups.com
Hi,

The ServiceUtils#computeMD5Hash(InputStream) method consumes and closes the input stream you give it. To send the same data to S3 after calculating the MD5 hash with this method, you will need to create a new input stream and provide this to the S3Service object.

If you are uploading files you should consider using one of the S3Object constructors that takes a File object, since this will do all the hashing work for you.

James



--
You received this message because you are subscribed to the Google Groups "JetS3t Users" group.
To post to this group, send email to jets3t...@googlegroups.com.
To unsubscribe from this group, send email to jets3t-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jets3t-users?hl=en.


Scott

unread,
Jul 16, 2010, 1:38:29 AM7/16/10
to JetS3t Users
Hi James, thanks for the answer.
> > jets3t-users...@googlegroups.com<jets3t-users%2Bunsubscribe@google groups.com>
> > .
Reply all
Reply to author
Forward
0 new messages