# Saving a base64 image to the media manager with Velo

**URL:** <https://forum.wixstudio.com/t/saving-a-base64-image-to-the-media-manager-with-velo/57096>\
**Category:** Ask the community\
**Tags:** api, code\
**Created:** [March 10, 2024, 12:18am UTC](https://forum.wixstudio.com/t/saving-a-base64-image-to-the-media-manager-with-velo/57096 "2024-03-10T00:18:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PicsGenie](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/picsgenie/32/89438_2.png) [@PicsGenie](https://forum.wixstudio.com/u/PicsGenie)\
**Post date:** [March 10, 2024, 12:18am UTC](https://forum.wixstudio.com/t/saving-a-base64-image-to-the-media-manager-with-velo/57096/1 "2024-03-10T00:18:33Z")

</div>

I’m trying to figure out how to use importFile() or something similar to save a base64 image (loaded in the end user’s browsing session on my site) to Media Manager. I want to save it to media manager and get a link to it.

---

<div class="post-metadata">

**Author:** ![PicsGenie](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/picsgenie/32/89438_2.png) [@PicsGenie](https://forum.wixstudio.com/u/PicsGenie)\
**Post date:** [March 10, 2024, 6:25am UTC](https://forum.wixstudio.com/t/saving-a-base64-image-to-the-media-manager-with-velo/57096/2 "2024-03-10T06:25:08Z")

</div>

I’m using the upload() function with this backend code:

```javascript
export const importFile = webMethod(Permissions.Anyone, (url) => {

  return mediaManager.importFile(

    "/myImportFolder/subfolder",

    url,

    {

      "mediaOptions": {

        "mimeType": "image/jpg",

        "mediaType": "image"

      },

      "metadataOptions": {

        "isPrivate": false,

        "isVisitorUpload": false,

        "context": {

          "someKey1": "someValue1",

          "someKey2": "someValue2"

        }

      }

    }

  );

```

and this frontend code:

```javascript

import {Buffer} from "buffer";
import {sendToMediaManager} from "backend/mediaManagerInterface.web";
let b64Img = "data:image/jpeg;base64,/9j/4AAQ........" // for example
let uploadBuffer = Buffer.from(b64Img, "base64")

sendToMediaManager(uploadBuffer)
  

```

I keep getting this error:

Error: Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.

---

<div class="post-metadata">

**Author:** ![thewixwiz](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thewixwiz/32/105914_2.png) [@thewixwiz](https://forum.wixstudio.com/u/thewixwiz)\
**Post date:** [March 18, 2024, 3:03am UTC](https://forum.wixstudio.com/t/saving-a-base64-image-to-the-media-manager-with-velo/57096/3 "2024-03-18T03:03:47Z")

</div>

“importFile” is for uploading via a url. For a buffer you need to use this API:

> **[upload - Velo API Reference - Wix.com](https://www.wix.com/velo/reference/wix-media-backend/mediamanager-obj/upload)**
>
> Uploads a file to the Media Manager from a buffer. The upload() function returns a Promise that resolves to information about the newly uploaded file. Video ...

Also you may need to generate the buffer itself in the backend.

If you’re still encountering the same error please upload a screenshot of the log from your site events.
