Media POST

Upload media to your account.

Uploading Images

Datasquirel media API allows you to upload both public and private images to your account. There are default file types which are allowed, but can be extended from the super admin panel.

Using node/bun:

import datasquirel from "@moduletrace/datasquirel";

datasquirel.api
    .media({
        key: process.env.FULL_ACCESS_API_KEY,
        params: {
            media: [
                {
                    imageBase64: "==base64-long-string==",
                    imageName: "Squirrel Robot",
                    imageType: "png",
                },
            ],
            type: "image",
        },
    })
    .then((response) => {
        console.log(response);
    });

Using curl:

CURL -X POST https://datasquirel.com/api/v1/media \
-H "Authorization:FULL_ACCESS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "media": [
        {
            "imageBase64": "==base64-long-string==",
            "imageName": "Squirrel Robot",
            "imageType": "png",
        }
    ],
    "type": "image"
}'

Return Response:

{
    success: true,
    payload: {
        media_url: "/squirrel-robot.png",
        media_thumbnail_url: "/squirrel-robot.png",
    },
}

Uploading Files

Datasquirel media API allows you to upload both public and private files to your account. There are default file types which are allowed, but can be extended from the super admin panel.

Using node/bun:

import datasquirel from "@moduletrace/datasquirel";

datasquirel.api
    .media({
        key: process.env.FULL_ACCESS_API_KEY,
        params: {
            media: [
                {
                    fileBase64: "==base64-long-string==",
                    fileName: "API Test File",
                    fileType: "yaml",
                },
            ],
            type: "file",
            folder: "folder-name/sub-folder",
        },
    })
    .then((response) => {
        console.log(response);
    });

Using curl:

CURL -X POST https://datasquirel.com/api/v1/media \
-H "Authorization:FULL_ACCESS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "media": [
        {
            "fileBase64": "==base64-long-string==",
            "fileName": "API Test File",
            "fileType": "yaml",
        }
    ],
    "type": "file",
    "folder": "folder-name/sub-folder"
}'

Return Response:

{
    success: true,
    payload: {
        media_url: "/folder-name/sub-folder/api-test-file.yaml",
    },
}

Uploading videos

Videos are uploaded in the same way as files, but with a different type. Eg mp4 and webm.


Handling Folders

Datasquirel media API allows you to upload media to both public and private folders.

Using node/bun:

import datasquirel from "@moduletrace/datasquirel";

datasquirel.api
    .media({
        key: process.env.FULL_ACCESS_API_KEY,
        params: {
            media: [
                {
                    fileBase64: "==base64-long-string==",
                    fileName: "API Test File",
                    fileType: "yaml",
                    private: true,
                    privateFolder: true,
                },
            ],
            type: "file",
            folder: "private-folder",
        },
    })
    .then((response) => {
        console.log(response);
    });