Access list of added files via Dialog API or similar


I have a custom Media Library tab and I would like to prevent the same media from being added more then once to the “Preview” tab. Media is added by passing it with the dialogApi.addFiles method.

I explored the dialogApi.fileColl collection and found an __items array but I am unsure how to interact with it.

Curious if there is a recommendation for how to compare a file to be added via dialogApi.addFiles([uploadcare.fileFrom('uploaded', uuid, settings)]);
with a list of files that has already been added.


Hi Owen,

Alex here from Uploadcare support. Thanks for the question!

The __items array contains instances of files loaded to the widget (the same list that you can see on the preview tab). A file instance is a promise-like object, and you can use its done method to get file information. For example,

dialog.fileColl.__items[0].done(fileInfo => {

The uploadcare.fileFrom('uploaded', uuid, settings) method returns a file instance as well. From the fileInfo object, you can get UUID of the file and use it to compare files to find if they are the same.

Does this answer your question?