We are often asked why the following construct doesn’t return information about the file:
dialog.done(function(result) {
// Dialog closed and file or filegroup chosen.
});
The result in this context is a file promise object, or a fileGroup promise object if it’s a multi-file widget. It implements jQuery.promise
interface. This is done because objects might not be available immediately, but you still would want to use it in your code (i.e to subscribe additional callbacks)
Here is an example of code that extracts actual file information from the file.
uploadcare.openDialog(null, {
publicKey: 'demopublickey',
imagesOnly: true,
crop: "1:1",
doNotStore: true,
imageShrink: "600x600"
}).done(function(file) {
// this is a promise
if (file) { // promise was completed
file.done(function(fileInfo) {
// this is an object with all the relevant file information
console.log(fileInfo.uuid);
});
}
});
In this example, file UUID will be outputted in the console. If you need any additional information about the file, look through our docs here.