You are right - if you have S3 configured then you will end up with 2 files if you do pick() and then store() afterwards.
The file that is created by pick() will be on the root level of your S3 bucket.
I didn't find a way to avoid that, so I ran with pick(), store() and remove() - as those are async functions you need to nest them, or (better) use the flow control of your choice.
If you don't need to do anything between pick() and store() then you could do pickAndStore(), if you need information from the pick() call before doing the store() request, go with the example below:
var file;
// authenticate
filepicker.setKey('YOUR_API_KEY');
// pick
filepicker.pick({
container : 'modal',
debug : false,
extensions : ['.png', '.jpg', '.jpeg', '.gif'],
folders : false,
language : 'en',
maxFiles : 1,
maxSize : '2560*1600',
multiple : false,
openTo : 'COMPUTER',
services : [
'BOX',
'COMPUTER'
]
}, function(res) {
// save blob, to remove it later
file = res;
// store
filepicker.store(file, {
access : 'public',
container : 'YOUR_BUCKET',
location : 'S3',
path : 'SOME_FOLDER/ANOTHER_FOLDER/FILENAME.png'
}, function(res) {
// remove
filepicker.remove(file, function() {
console.log('ok')
});
});
});