To import files using the Import File or Bulk Import File endpoints, you need to do one of the following for each file:
Pass its MIME type in the mimeType
field of the request. For example, mimeType: 'image/jpeg'
.
Include its extension in either the displayName
or url
field of the request. For example, displayName: 'Example Image.jpeg
or url: https://www.example.com/image.jpeg
.
Ensure the server hosting the file supports HEAD requests. In these cases the Wix servers can retrieve the MIME type from the hosting server.
Note: If you want to validate the media type, pass the file's expected media type in the optional mediaType
field of the request. For example, mediaType: 'IMAGE'
.
When you import a file using the Import File or Bulk Import File endpoint, or upload a file, it's not immediately available, meaning you can't manage or use the file straight away. Files can take time to import or upload and be processed. This is true even though the endpoint used to import or upload a file returns a successful response.
To run code when a file finishes processing successfully, use the File Ready webhook. To run code when a file's import fails, use the File Failed webhook.
externalInfo
The Import File, Bulk Import File, Generate File Upload URL, and Generate File Resumable Upload URL endpoints have a parameter called externalInfo
.
Arguments passed to this parameter are included in the event bodies of the File Ready and File Failed webhooks. This is the only place they appear.
Use externalInfo
to pass information to the webhooks that isn't contained in the file descriptor object.
externalInfo
use caseHere is a sample flow to show how you could use externalInfo
effectively.
There is a form on a site that sends site visitors a confirmation email with the details they submitted in the form. One of the form fields is an image URL. In the email, we want to send a Wix download URL for the image, not the original image URL. This means we can only send the email when the image file is ready to download.
To implement this, we use the following flow:
id
.externalInfo
parameter as follows:
externalInfo.origin
is formBuilder
. We don't want to run this code if media was added from a different source.id
to retrieve the form details from the CMS.