Skip to main content

I’m attempting to use the Box Embed widget to serve as a file uploader – from the parent application, I would like to listen for events for things like onFileUpload, onFileDelete, etc. I’m wondering if the widget broadcasts any messages that would allow me to do this?



The problem I am trying to solve is to upload a file to the Box embed widget, and then store the file path of the newly uploaded file in the parent applications backend. But currently I do not receive any information back after the onFileUpload event, so the parent application does not know what the uploaded file path is.



I’m open to any and all other approaches that might unlock that. Thanks in advance for any guidance.

Hi there,



Thanks for your question! Have you considered using Content Uploader Box UI Element? It includes dedicated events eg. upload which returns a bunch of information related to the uploaded file.



Example of logging data related to the uploaded file:



                const contentUploader = new Box.ContentUploader();

contentUploader.show(folderId, accessToken , {

container: "#box-content-uploader",

});

contentUploader.on('upload', (data) => {

console.log(data.path_collection)

console.log(data.parent)

console.log(data.id)

});



Installation:





Events related to Content Uploader:





Let me know if that helps!



Cheers,


Olga


Hi Olga – Thanks for your reply. Unfortunately I’m currently unable to utilize the ‘box-ui-elements’ package in this particular application, given it’s package size and the large number of peer dependencies required to be maintained.


Hi there, just one more question in this regard. Have you checked the possibility to include the UI Element using a CDN script link? This will not require package installation. You can include a single component, no requirement to add all of them.


Reply