How to write a string to Amazon S3 bucket?

后端 未结 7 553
花落未央
花落未央 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:50

    There is a simple way to do it with PHP, simply send the string as the body of the object, specifying the name of the new file in the key -

    $s3->putObject(array(
            'Bucket'       => [Bucket name],
            'Key'          => [path/to/file.ext],
            'Body'         => [Your string goes here],
            'ContentType'  => [specify mimetype if you want],
        ));
    

    This will create a new file according to the specified key, which has a content as specified in the string.

提交回复
热议问题