# Upload Media Asset — Cloudinary

> Upload media assets such as images or videos. See the documentation

- Key: `cloudinary-upload-media-asset`
- Type: Action (Write)
- Version: 1.0.4
- App: Cloudinary (`cloudinary`) — https://pipedream.com/apps/cloudinary.md
- This page (HTML): https://pipedream.com/apps/cloudinary/actions/upload-media-asset
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/cloudinary/actions/upload-media-asset/upload-media-asset.mjs

## Description

Upload media assets such as images or videos. [See the documentation](https://cloudinary.com/documentation/image_upload_api_reference#upload_method)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `file` | `string` | Yes | The file to upload. You can provide a file path from the /tmp folder (e.g. /tmp/myFile.jpg) or a public file URL, among other options supported by Cloudinary (see the documentation for available options). |
| `publicId` | `string` | No | The identifier that is used for accessing the uploaded asset. See the documentation for more information. |
| `folder` | `string` | No | An optional folder name where the uploaded asset will be stored. The public ID contains the full path of the uploaded asset, including the folder name. |
| `resourceType` | `string` | No | Set the type of file you are uploading or use auto to automatically detect the file type. Valid values: image, raw, video and auto. Defaults: image for server-side uploading and auto for client-side uploading. Note: Use the video resource type for all video assets as well as for audio files, such as .mp3. |
| `type` | `string` | No | The delivery type. Allows uploading assets as private or authenticated instead of the default upload mode. |
| `accessMode` | `string` | No | Allows the asset to behave as if it's of the authenticated 'type'. Default is public. The asset can later be made public by changing its Access Mode via the Admin API, without having to update any delivery URLs. |
| `tags` | `string[]` | No | An array of tag names to assign to the uploaded asset for later group reference. |
| `format` | `string` | No | An optional format to convert the uploaded asset to before saving in the cloud, e.g. jpg. |
| `backup` | `boolean` | No | Tell Cloudinary whether to back up the uploaded asset. Overrides the default backup settings of your account. |
| `additionalOptions` | `object` | No | Additional parameters and their values to use in the upload. See the documentation for all available options. Values will be parsed as JSON where applicable. Example: { "use_filename": true } |
| `syncDir` | `dir` | No | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "cloudinary",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "cloudinary-upload-media-asset",
  arguments: {
    file: "File Path or URL",
    publicId: "Public Id",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "cloudinary-upload-media-asset",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    cloudinary: { authProvisionId: "apn_xxxxxxx" },
    file: "File Path or URL",
    publicId: "Public Id",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "cloudinary-upload-media-asset",
    "configured_props": {
      "cloudinary": { "authProvisionId": "apn_xxxxxxx" },
      "file": "File Path or URL",
      "publicId": "Public Id"
    }
  }'
```

---

- App: https://pipedream.com/apps/cloudinary.md · All apps: https://pipedream.com/apps
