> 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

# GenerateFileUploadUrl

# Package: richContent

# Namespace: RicosDocument

# Method link: https://dev.wix.com/docs/api-reference/assets/rich-content/ricos-documents/generate-file-upload-url.md

## Permission Scopes:
Manage Ricos Document: SCOPE.DC-RICOS.MANAGE-DOCUMENTS

## Introduction

Generates a URL for uploading a file to the site's Media Manager, so you can add the file to a Ricos document.

To upload the file, send a `PUT` request to `uploadUrl` with the file content as the request body and a
`Content-Type` header that matches `mimeType`. If you didn't specify `fileName`, add the file name as the
`filename` query parameter. For example, `PUT {uploadUrl}?filename=report.pdf`. The URL expires after 24 hours.
Learn more about the [Upload API](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md).

The upload response contains the uploaded file's
[file descriptor](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-object.md).
Specify its `file.id` as the file node's `fileData.src.id` in the Ricos document.
A successful upload response doesn't mean the file is ready. To run code when it's ready, listen for the
[File Ready](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-file-ready.md) and
[File Failed](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-file-failed.md) events.

Use this method to let site visitors and members add files to the content they create.
To download a private file, call [Generate File Download URL](https://dev.wix.com/docs/api-reference/assets/rich-content/ricos-documents/generate-file-download-url.md).

This method doesn't support resumable uploads. For the supported file types and sizes, 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).

---

## REST API

### Schema

```
 Method: generateFileUploadUrl
 Description: Generates a URL for uploading a file to the site's Media Manager, so you can add the file to a Ricos document.  To upload the file, send a `PUT` request to `uploadUrl` with the file content as the request body and a `Content-Type` header that matches `mimeType`. If you didn't specify `fileName`, add the file name as the `filename` query parameter. For example, `PUT {uploadUrl}?filename=report.pdf`. The URL expires after 24 hours. Learn more about the [Upload API](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md).  The upload response contains the uploaded file's [file descriptor](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-object.md). Specify its `file.id` as the file node's `fileData.src.id` in the Ricos document. A successful upload response doesn't mean the file is ready. To run code when it's ready, listen for the [File Ready](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-file-ready.md) and [File Failed](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-file-failed.md) events.  Use this method to let site visitors and members add files to the content they create. To download a private file, call [Generate File Download URL](https://dev.wix.com/docs/api-reference/assets/rich-content/ricos-documents/generate-file-download-url.md).  This method doesn't support resumable uploads. For the supported file types and sizes, 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).
 URL: https://www.wixapis.com/ricos/v1/ricos-document/generate-file-upload-url
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  mimeType
 Method parameters: 
   param name: fileName | type: fileName | description: Name of the file as it appears in the Media Manager.  | validation: maxLength 1000
   param name: mimeType | type: mimeType | description: MIME type of the file to upload. For example, `application/pdf`. | required: true | validation: maxLength 255
   param name: parentFolderId | type: parentFolderId | description: GUID of the Media Manager folder to upload the file to. Learn more about [folders](https://dev.wix.com/docs/api-reference/assets/media/media-manager/folders/introduction.md).  Default: Media Manager root folder  | validation: maxLength 100
   param name: private | type: private | description: Whether the file is private. Private files can't be accessed from their file URL. To download a private file, call [Generate File Download URL](https://dev.wix.com/docs/api-reference/assets/rich-content/ricos-documents/generate-file-download-url.md).  Default: `false`  
 Return type: GenerateFileUploadUrlResponse
  - name: uploadUrl | type: string | description: URL to upload the file to with a `PUT` request. Expires after 24 hours.  | validation: format WEB_URL


```

### Examples

### Generate an upload URL for a private file
```curl
curl -X POST \
'https://www.wixapis.com/ricos/v1/ricos-document/generate-file-upload-url' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "mimeType": "application/pdf",
  "fileName": "report.pdf",
  "private": true
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.richContent.ricosDocuments.generateFileUploadUrl(mimeType, options)
 Description: Generates a URL for uploading a file to the site's Media Manager, so you can add the file to a Ricos document.  To upload the file, send a `PUT` request to `uploadUrl` with the file content as the request body and a `Content-Type` header that matches `mimeType`. If you didn't specify `fileName`, add the file name as the `filename` query parameter. For example, `PUT {uploadUrl}?filename=report.pdf`. The URL expires after 24 hours. Learn more about the [Upload API](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md).  The upload response contains the uploaded file's [file descriptor](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-object.md). Specify its `file.id` as the file node's `fileData.src.id` in the Ricos document. A successful upload response doesn't mean the file is ready. To run code when it's ready, listen for the [File Ready](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-file-ready.md) and [File Failed](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/file-descriptor-file-failed.md) events.  Use this method to let site visitors and members add files to the content they create. To download a private file, call [Generate File Download URL](https://dev.wix.com/docs/api-reference/assets/rich-content/ricos-documents/generate-file-download-url.md).  This method doesn't support resumable uploads. For the supported file types and sizes, 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).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  mimeType
 Method parameters: 
   param name: mimeType | type: string | description: MIME type of the file to upload. For example, `application/pdf`. | required: true | validation: maxLength 255
   param name: options | type: GenerateFileUploadUrlOptions  none  
        - name: fileName | type: string | description: Name of the file as it appears in the Media Manager.  | validation: maxLength 1000
        - name: parentFolderId | type: string | description: GUID of the Media Manager folder to upload the file to. Learn more about [folders](https://dev.wix.com/docs/api-reference/assets/media/media-manager/folders/introduction.md).  Default: Media Manager root folder  | validation: maxLength 100
        - name: private | type: boolean | description: Whether the file is private. Private files can't be accessed from their file URL. To download a private file, call [Generate File Download URL](https://dev.wix.com/docs/api-reference/assets/rich-content/ricos-documents/generate-file-download-url.md).  Default: `false`  
 Return type: PROMISE<GenerateFileUploadUrlResponse>
  - name: uploadUrl | type: string | description: URL to upload the file to with a `PUT` request. Expires after 24 hours.  | validation: format WEB_URL


```

### Examples

### Generate an upload URL for a private file
```javascript
import { ricosDocuments } from "@wix/rich-content";

async function generateFileUploadUrl() {
  const response = await ricosDocuments.generateFileUploadUrl("application/pdf", {
    fileName: "report.pdf",
    private: true,
  });
}

/* Promise resolves to:
 * {
 *   "uploadUrl": "https://upload.wixmp.com/upload/<UPLOAD_TOKEN>"
 * }
 */

```

### generateFileUploadUrl (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { ricosDocuments } from '@wix/rich-content';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { ricosDocuments },
  // Include the auth strategy and host as relevant
});


async function generateFileUploadUrl(mimeType,options) {
  const response = await myWixClient.ricosDocuments.generateFileUploadUrl(mimeType,options);
};
```

---