> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Files ## Article: Importing Files ## Article Link: https://dev.wix.com/docs/velo/apis/wix-media-v2/files/importing-files.md ## Article Content: # Importing Files To import files using the [`importFile()`](/wix-media-v2/files/import-file) or [`bulkImportFile()`](/wix-media-v2/files/bulk-import-file) functions, you need to do one of the following for each file: - Pass its [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) 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'`. ## Knowing when a file is ready When you import a file using the [`importFile()`](/wix-media-v2/files/import-file) or [`bulkImportFile()`](/wix-media-v2/files/bulk-import-file) function, or [upload a file](/wix-media-v2/files/upload-api), 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 function used to import or upload a file returns a successful response. To run code when a file finishes processing successfully, use the [`onFileDescriptorFileReady()`](/wix-media-v2/events/on-file-descriptor-file-ready) event. To run a code block when a file's import fails, use the [`onFileDescriptorFileFailed()`](/wix-media-v2/events/on-file-descriptor-file-failed) event. ## Using `externalInfo` The [`importFile()`](/wix-media-v2/files/import-file), [`bulkImportFile()`](/wix-media-v2/files/bulk-import-file), [`generateFileUploadUrl()`](/wix-media-v2/files/generate-file-upload-url), and [`generateFileResumableUploadUrl()`](/wix-media-v2/files/generate-file-resumable-upload-url) functions have a parameter called `externalInfo`. Arguments passed to this parameter are included in the event bodies of the [`onFileDescriptorFileReady()`](/wix-media-v2/events/on-file-descriptor-file-ready) and [`onFileDescriptorFileFailed()`](/wix-media-v2/events/on-file-descriptor-file-failed) events. This is the only place they appear. Use `externalInfo` to pass information to the events that isn't contained in the file descriptor object. ### `externalInfo` use case Here 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: 1. When the user submits the form, send the form information to a [data collection](/wix-data/introduction), getting back the form data's `_id`. 1. Use [`importFile()`](/wix-media-v2/files/import-file) to upload the image to the Media Manager. Include the `externalInfo` parameter as follows: ```json { "externalInfo": { "origin": "formBuilder", "externalIds": ["_id"] } } ``` 1. Add the [`onFileDescriptorFileReady()`](/wix-media-v2/events/on-file-descriptor-file-ready) event in your **events.js** file, and implement the following steps to handle the event: 1. Check that the value for `externalInfo.origin` is `formBuilder`. We don't want to run this code if media was added from a different source. 1. Use the form data's `_id` to [retrieve the form details](/wix-data/get) from the CMS. 1. [Generate a download URL](/wix-media-v2/files/generate-file-download-url) for the image. 1. Send the confirmation email with the download URL and the rest of the form details.