> 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: getUploadUrl(path: string, options: UploadOptions)

# Method package: wixMediaBackend

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

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

# Method Description:

Gets an upload URL for uploading a file to the media manager.

The `getUploadUrl()` function returns a Promise that resolves to an object
 containing an upload URL.

 Use the `getUploadUrl()` function to allow an external client to upload a single file to your
 site's Media Manager.

>**Note:**
The upload URL is valid for a single file upload and expires after 1 day. The `getUploadUrl()` function must be called for each file that you want to upload. 


 The external client uploads a file by sending a POST or PUT request to the
 URL returned by `getUploadUrl()` using multipart/form-data encoding and
 sending the following data:

 ```javascript
 {
   "upload_url": ,
   "file": {
     "value": ,
     "options": {
       "filename": ,
       "contentType": 
     }
   }
 };
 ```

 + `upload_url`: The returned upload URL.
 + `file`: An object containing:
     
     + `value`: The file content as a multi-part value.
     + `options`: An object containing:
     
         + `filename`: The name of the file as it will appear in the Media Manager.
         + `contentType`: The content type of the file.


 The POST or PUT request returns the following:

   ```javascript
   [ 
     { 
       "parent_folder_id": ,
       "hash": ,
       "tags": [],
       "file_name": ,
       "refs": [],
       "labels": [] ,
       "site_id": ,
       "height": ,
       "original_file_name": ,
       "file_size": ,
       "width": ,
       "media_type": "picture",
       "mime_type": "image/jpeg"
     } 
   ]
   ```

 To get a Wix image URL that can be stored in a collection or displayed in an image
 element or gallery from the above object, use the following expression:

 ```
 let wixImageUrl = `wix:image://v1/${response[0].file_name}/${response[0].original_file_name}#originWidth=${response[0].width}&originHeight=${response[0].height}`;
 ```



# Method Code Examples:

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

## Generate a URL for uploading a file

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

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

## Use the generated `uploadUrl` to send a PUT request to upload an image

```javascript
/********************************
 * External Node.js application *
********************************/

import axios from 'axios';

async function myUploadImageFunction(uploadUrl, contentStream, fileName, contentType) {
  const response = await axios.put(uploadUrl, contentStream, {
    headers: {
      'Content-Type': contentType
    },
    params: {
      filename: fileName
    }
  });
   
  return `wix:image://v1/${response[0].file_name}/${response[0].original_file_name}#originWidth=${response[0].width}&originHeight=${response[0].height}`;
} 
```

## Use the generated upload URL to send a POST request to upload an image

```javascript
/********************************
 * External Node.js application *
********************************/

import axios from 'axios';
import FormData from 'form-data';

async function myUploadImageFunction(uploadUrl: string, fileName: string, content: Buffer | fs.ReadStream | string) {
  const formData = new FormData({});
  formData.append('file', content, {
    filename: fileName,
    contentType: 'image/jpeg',
  });

  const uploadResponse = await axios.post(
    uploadUrl,
    formData,
    {
      headers: formData.getHeaders()
    });
 
  return uploadResponse;
}
```

---