How to write a string to Amazon S3 bucket?

后端 未结 7 554
花落未央
花落未央 2020-12-10 10:42

How can I add a string as a file on amazon s3? From whaterver I searched, I got to know that we can upload a file to s3. What is the best way to upload data without creating

7条回答
  •  旧巷少年郎
    2020-12-10 10:45

    There is an overload for the AmazonS3.putObject method that accepts the bucket string, a key string, and a string of text content. I hadn't seen mention of it on stack overflow so I'm putting this here. It's going to be similar @Jonik's answer, but without the additional dependency.

    AmazonS3 s3client = AmazonS3ClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
    s3client.putObject(bucket, key, contents);
    

提交回复
热议问题