如何写一个字符串到Amazon S3存储? [英] How to write a string to Amazon S3 bucket?

查看:190
本文介绍了如何写一个字符串到Amazon S3存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加一个字符串作为Amazon S3上的文件?从whaterver我搜索,我才知道,我们可以上传文件到S3。什么是上传数据,而无需创建文件的最好方法是什么?

解决方案
  

什么是上传数据的最佳方式   而无需创建文件?

如果你的意思是不会造成对S3的文件,好了,你不能真正做到这一点。在Amazon S3上,在的只有的方式来存储数据的文件,或者使用更精确的术语,对象的。一个对象可以包含来自的 1字节零字节至5兆兆字节的数据,并且被存储在一个的的。亚马逊的 S3网页,勾画出了基本事实很清楚。 (对于其他数据AWS存储选项,您可能需要阅读如约 SimpleDB的。)

如果你的意思,而无需创建本地临时文件,然后将答案取决于你使用的库/工具。 (由于RickMeasham建议,请补充详细信息!)随着s3cmd工具,例如,你不能跳过创建临时文件,同时用的JetS3t Java库直接上传一个字符串的会很容易

  //(首先初始化s3Service和testBucket)
S3Object stringObject =新S3Object(HelloWorld.txt,的Hello World!);
s3Service.putObject(testBucket,stringObject);
 

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 file?

解决方案

What is the best way to upload data without creating file?

If you meant without creating a file on S3, well, you can't really do that. On Amazon S3, the only way to store data is as files, or using more accurate terminology, objects. An object can contain from 1 byte zero bytes to 5 terabytes of data, and is stored in a bucket. Amazon's S3 homepage lays out the basic facts quite clearly. (For other data storing options on AWS, you might want to read e.g. about SimpleDB.)

If you meant without creating a local temporary file, then the answer depends on what library/tool you are using. (As RickMeasham suggested, please add more details!) With the s3cmd tool, for example, you can't skip creating temp file, while with the JetS3t Java library uploading a String directly would be easy:

// (First init s3Service and testBucket)
S3Object stringObject = new S3Object("HelloWorld.txt", "Hello World!");
s3Service.putObject(testBucket, stringObject);

这篇关于如何写一个字符串到Amazon S3存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆