> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: upload(path: string, fileContent: Buffer, fileName: string, options: UploadOptions)

# Method package: wixMediaBackend

# Method menu location: wixMediaBackend --> MediaManager --> upload

# Method Link: https://dev.wix.com/docs/velo/apis/wix-media-backend/media-manager/upload.md

# Method Description:

Uploads a file to the Media Manager from a [buffer](https://nodejs.org/api/buffer.html#buffer_static_method_buffer_from_string_encoding).

The `upload()` function returns a Promise that resolves to information about
 the newly uploaded file.

 Video and audio files that have been uploaded aren't immediately available
 to be used even after the Promise is resolved. Before they can be used, they
 must first undergo transcoding. The [`onFileUploaded()`](https://dev.wix.com/docs/velo/apis/wix-media-backend/events/on-file-uploaded.md)
 event is triggered when a file has been uploaded and before the transcoding is finished.

 To import a file to the Media Manager directly from a URL, use the [`importFile()`](#importfile) function.
 
 To enable site visitors to upload files to your site, you can also use an [upload button](https://www.wix.com/velo/reference/$w/uploadbutton).

 >**Notes:** 
 > - There are limits on the size and duration of files that you can upload. See [Wix Media: Supported Media File Types and File Sizes](https://support.wix.com/en/article/wix-media-supported-media-file-types-and-file-sizes) for more details.
 > - Receiving a response does not indicate that the import is complete. To run code when the upload finishes, implement the relevant [event](https://dev.wix.com/docs/velo/apis/wix-media-backend/events/introduction.md). See [Importing and Uploading Files](https://dev.wix.com/docs/velo/api-reference/wix-media-backend/importing-and-uploading-files.md) to learn more.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Upload a file

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { mediaManager } from 'wix-media-backend';

export const uploadImage = webMethod(Permissions.Anyone, (buffer) => {
  return mediaManager.upload(
    "/myUploadFolder/subfolder",
    buffer,
    "myFileName.jpg",
    {
      "mediaOptions": {
        "mimeType": "image/jpeg",
        "mediaType": "image"
      },
      "metadataOptions": {
        "isPrivate": false,
        "isVisitorUpload": false,
        "context": {
          "someKey1": "someValue1",
          "someKey2": "someValue2"
        }
      }
    }
  );
});

/*  Returns a promise that resolves to:
 *  {
 *    "mediaType": "image",
 *    "isPrivate": false,
 *    "sizeInBytes": 51085,
 *    "mimeType": "image/jpeg",
 *    "iconUrl": "wix:image://v1/f6c0f9_g2ae28cf29ec4639bc45698fee57cf56~mv2.jpg/myFileName.jpg#originWidth=300&originHeight=300",
 *    "fileUrl": "wix:image://v1/f6c0f9_g2ae28cf29ec4639bc45698fee57cf56~mv2.jpg/myFileName.jpg#originWidth=300&originHeight=300",
 *    "originalFileName": "myFileName.jpg",
 *    "hash": "bee2f8aab80b0d011499361c2eb189eb",
 *    "labels": [
 *      "Blue",
 *      "Butterfly",
 *      "Turquoise"
 *    ],
 *    "width": 300,
 *    "height": 300
 * }
 */
```

---