importFile( )


Imports a file to the Media Manager using an external URL.

The importFile() function returns a Promise that resolves to the imported file's descriptor.

This function returns information about the imported file. Importing a file is the method through which you can add files to the Media Manager. Use the parentFolderId and filePath parameters to specify which folder you want the file to be imported to. If no folder is specified, the file is imported to the media-root folder.

To import a file, you need to do one of the following:

  • 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'.

Admin Method

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Bookings Services and Settings
Manage Media Manager
Manage Restaurants - all permissions
Learn more about permission scopes.
Method Declaration
Copy
Method Parameters
urlstringRequired

Publicly accessible external file URL.


optionsImportFileOptions

Options to use when importing a single file.

Returns
Return Type:Promise<ImportFileResponse>
Was this helpful?
Yes
No