I'm using FileStack on my website, according to FileStack Docs I have this actually:
<iframe id="framefile" width="700" height="500" frameborder="0">
<p>Your browser does not support iframes.</p>
</iframe>
<div id="files"></div>
And in javascript side:
<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="http://api.filepicker.io/v2/filepicker.js"></script>
<script type="text/javascript">
filepicker.setKey("myAPIKey");
filepicker.pickMultiple(
{
mimetype: '*/*',
language: 'es_mx',
container: 'framefile',
services: ['COMPUTER','GOOGLE_DRIVE','DROPBOX']
},
function(Blobs){
console.log(JSON.stringify(Blobs));
},
function(FPError){
console.log(FPError.toString());
});
</script>
I need to get only URL files values and put it in a div. I tried this:
<script type="text/javascript">
filepicker.setKey("myAPIKey");
filepicker.pickMultiple(
{
mimetype: '*/*',
language: 'es_mx',
container: 'framefile',
services: ['COMPUTER','GOOGLE_DRIVE','DROPBOX']
},
function(Blobs){
console.log(JSON.stringify(Blobs));
var result = JSON.stringify(Blobs, ['url']);
$('#files').html(result);
},
function(FPError){
console.log(FPError.toString());
});
</script>
I obtain this:
[{"url":"https://cdn.filepicker.io/api/file/--link1--"}]
But How can I obtain URL values but in this way?:
Anyone have a solution?
You're almost there, are not you?
What about appending
[0].url
to the object which is returned ?I mean substituting
result = JSON.stringify(Blobs, ['url']);
forresult = JSON.stringify(Blobs, ['url'])[0].url
;UPDATE
My first anwser is wrong because
result
inreturns
'[{"url":"https://cdn.filepicker.io/api/file/--link1--"}]'
, which is a string since it comes from astringify
ed variable. Thus,result[0]
returns its first character, which is"["
. Finalyresult[0].url
or put differently,"[".url
is undefined. (and can hardly be so)Replace this part:
by
If one wants to get the desired information from a json, one must not
stringify
it.Update
Or if you want to display numerous urls, because of multiple files replace the latter method by