---
title: "Tiny Drive Upload API"
description: "Using the Tiny Drive Upload API"
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/tinydrive-upload/"
md_url: "https://www.tiny.cloud/docs/tinymce/7/tinydrive-upload/index.md"
version: "7"
last_updated: "2022-03-30T07:08:51Z"
tokens: 318
---
Important This page documents TinyMCE 7. For new projects, Tiny recommends using the latest, most up-to-date version. [See TinyMCE 8 documentation](../../latest/tinydrive-upload/).
# Tiny Drive Upload API

The `tinydrive.upload` method allows [blob objects](https://developer.mozilla.org/en-US/docs/Web/API/Blob) to be uploaded directly to Tiny Drive. This can be useful when you want to store a file generated by your application.

## Interactive example: Using `tinydrive.upload`

**Example**

```js
tinymce.init({
  selector: 'textarea#drive-upload-example',
  height: 200,
  menubar: false,
  plugins: 'tinydrive link image media',
  toolbar: 'custom | insertfile | link image media',
  tinydrive_token_provider: 'URL_TO_YOUR_TOKEN_PROVIDER',
  setup: (editor)  => {
    editor.ui.registry.addButton('custom', {
      text: 'Custom upload',
      onAction: ()  => {
        editor.plugins.tinydrive.upload({
          path: '/hello',
          name: 'hello.txt',
          blob: new Blob(['Hello world!']),
          onprogress: (progress) => {
            console.log('upload progess', progress);
          }
        }).then((result) => {
          const link = editor.dom.createHTML('a', { href: result.file.url }, editor.dom.encode(result.file.name));
          editor.insertContent(link);
        });
      }
    });
  }
});
```
