Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize segmented upload of Amazon S3 data files

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report