Search...
onFileUploaded( )
An event that triggers when a file has completed uploading.
Description
The onFileUploaded()
event handler runs when a file has been uploaded to
to the Media Manager using the importFile()
,
upload()
function, or the URL
returned by the getUploadUrl()
function.
The FileEvent
object contains information about the uploaded file and the upload context.
Note: Backend events don't work when previewing your site.
Syntax
function onFileUploaded(event: FileEvent): void
onFileUploaded Parameters
NAME
TYPE
DESCRIPTION
event
FileEvent
The uploaded file information.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event when a file has been uploaded
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.34export function wixMediaManager_onFileUploaded(event) {5 let allFileInfo = event.fileInfo;6 let fileUrl = event.fileInfo.fileUrl;7 let mediaHeight = event.fileInfo.height;8}910/* Full event object:11 * {12 * "fileInfo": {13 * "mediaType": "image",14 * "height": 300,15 * "sourceUrl": "https://somedomain.com/img/original-name.jpg",16 * "mimeType": "image/jpeg",17 * "hash": "Ew00kXbu4Zt33rzjcWa6Ng==",18 * "opStatus": "READY",19 * "labels": [20 * "Blue",21 * "Butterfly",22 * "Turquoise"23 * ],24 * "fileUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",25 * "originalFileName": "original-name.jpg",26 * "sizeInBytes": 51085,27 * "isPrivate": false,28 * "width": 300,29 * "iconUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",30 * "parentFolderId": "2bf470f5be194b319cdb2fvbu3278ff9"31 * },32 * context: {33 * someKey1: "someValue1",34 * someKey2: "someValue2"35 * }36 * }37 */