我在网上读到可以使用流星弹弓将 blob 字符串上传到 aws。唯一的问题是,每当我将 blob 传递给上传者时,我都会得到一个edgee_slingshot.js:283 Uncaught Error: Not a file
.
我从我的裁剪器中得到这个对象:
{
width: 300,
height: 168,
type: "png",
string: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAokEjHVW7m2KLDU//lU/Of7KFtKzGCDnwAAAAASUVORK5CYII="
}
然后我将字符串提取为我的 blob:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS.....CDnwAAAAASUVORK5CYII=
然后上传者:
let uploader = new Slingshot.Upload("example");
uploader.send(blob, function(error, url) {
if (error) {
console.log(error, "An error happened during the upload.");
}
if (!error) {
console.log("success, here is the url: ", url);
}
});
通过控制台,我可以看到错误是从以下位置抛出的:
send: function (file, callback) { // 88
if (! (file instanceof window.File) && ! (file instanceof window.Blob)) // 89
throw new Error("Not a file");