我正在尝试使用Filestack(Filepicker)V3上传多个文件并获取文件名,网址和mimetype。所以根据这个新版本的Filestack文档并跟随a similar question before我有这个:
var client = filestack.init('myapikey');
client.pick({
accept: 'image/*',
fromSources: ['local_file_system','googledrive','gmail','facebook','dropbox','onedrive','webcam'],
maxFiles: 5,
imageMax: [1024, 1024]
}).then(function(Blobs) {
console.log(JSON.stringify(Blobs));
var result = "";
for(var i=0; i<Blobs.length; i++){
result+=Blobs[i].filename + " : " + Blobs[i].url + " : " + Blobs[i].mimetype;
}
alert(result);
});
例如我上传了2个文件,在控制台中结果如下:
{"filesUploaded":[{"filename":"diploma1.jpg","handle":"1e3CkeZQaeokzS9TpcJM","mimetype":"image/jpeg","originalPath":"diploma1.jpg","size":258169,"source":"local_file_system","url":"https://cdn.filestackcontent.com/1e3CkeZQaeokzS9TpcJM","originalFile":{"customName":"diploma1.jpg"},"status":"Stored"},{"filename":"diploma2.jpg","handle":"kOejeHySTSG0TuSJWWlh","mimetype":"image/jpeg","originalPath":"diploma2.jpg","size":31072,"source":"local_file_system","url":"https://cdn.filestackcontent.com/kOejeHySTSG0TuSJWWlh","originalFile":{"customName":"diploma2.jpg"},"status":"Stored"}],"filesFailed":[]}
但警报显示没有结果,我想得到这样的警报结果:
diploma1.jpg : https://cdn.filestackcontent.com/1e3CkeZQaeokzS9TpcJM : image/jpeg
diploma2.jpg : https://cdn.filestackcontent.com/kOejeHySTSG0TuSJWWlh : image/jpeg
我想要一些帮助。
答案 0 :(得分:1)
我正在寻找有关结果控制台的一些信息,并基于此question我修改了我的代码,最终得到了我的结果:
var client = filestack.init('myapikey');
client.pick({
accept: 'image/*',
fromSources: ['local_file_system','googledrive','gmail','facebook','dropbox','onedrive','webcam'],
maxFiles: 5,
imageMax: [1024, 1024]
}).then(function(Blobs) {
console.log(JSON.stringify(Blobs));
var result = JSON.parse(JSON.stringify(Blobs));
var res = "";
for(var i=0; i<result.filesUploaded.length; i++){
res+=result.filesUploaded[i].filename + " : " + result.filesUploaded[i].url + " : " + result.filesUploaded[i].mimetype + "\n";
}
alert(res);
});
:)