How to realize segmented upload of Amazon S3 data files
This article introduces you how to achieve Amazon S3 data file segment upload, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Explore whether data can be streamed to S3
Usually, uploading data to S3 with Java code in our project is something like the following
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient ()
S3Client.putObject ("bucket_name", "s3key.txt", new ByteArrayInputStream ("hello" .getBytes ()), new ObjectMetadata (); / / ObjectMetadata can be null if there is nothing special.
Although the third parameter of putObject () is a stream, it is an input stream, not an output stream. In other words, when executing this method, all the data to be uploaded must be prepared in this input stream, so here we directly use a ByteArrayInputStream to wrap the data content that needs to be uploaded to S3.
Of course, putObject () will not be able to stream content to the file like FileObjectOutputStream, because putObject () is not associated with that file on bucket. Not even with PipedInputStream/PipedOutputStream, for example, the following code reads the full text > >
On how to achieve segmented upload of Amazon S3 data files to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.