从浏览器直接将字符串上传到s3,而无需本地文件 [英] direct upload string from browser to s3 without local file
本文介绍了从浏览器直接将字符串上传到s3,而无需本地文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用javascript,node.js和aws sdk.有很多关于使用签名URL直接将现有文件上传到S3的示例,但是现在我尝试上传字符串并在S3中创建文件,而没有任何本地保存的文件.有什么建议吗?
I am using javascript, node.js and aws sdk. There are many examples about uploading existing files to S3 directly with signed URL, but now I am trying to upload strings and create a file in S3, without any local saved files. Any suggestion, please?
推荐答案
尚未尝试 amazon-web-services
, amazon-s3
或 aws-sdk
,尽管如果您能够上传 File
或 FormData
对象,则可以在JavaScript上创建一个或两个对象,然后上传对象.
Have not tried amazon-web-services
, amazon-s3
or aws-sdk
, though if you are able to upload File
or FormData
objects you can create either or both at JavaScript and upload the object.
// create a `File` object
const file = new File(["abc"], "file.txt", {type:"text/plain"});
// create a `Blob` object
// will be converted to a `File` object when passed to `FormData`
const blob = new Blob(["abc"], {type:"text/plain"});
const fd = new FormData();
fd.append("file", blob, "file.txt");
这篇关于从浏览器直接将字符串上传到s3,而无需本地文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文