1

I'm trying with Filestack (Filepicker) V3 to upload multiple files and get filename, url and mimetype. So according to Filestack docs for this new release and following a similar question before I have this:

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);

    });

For example I upload 2 files, in console the result is like:

{"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":[]}

But alert shows no result and I want to get alert result like this:

diploma1.jpg : https://cdn.filestackcontent.com/1e3CkeZQaeokzS9TpcJM : image/jpeg
diploma2.jpg : https://cdn.filestackcontent.com/kOejeHySTSG0TuSJWWlh : image/jpeg

I would like some help.

NekoLopez
  • 579
  • 1
  • 9
  • 28

1 Answers1

1

I was looking for some information about result console and based on this question I modified my code to finally get my result:

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);

    });

:)

NekoLopez
  • 579
  • 1
  • 9
  • 28