Uploading Media to NewSpark: Simple vs Multipart Uploads

General

Developers integrating with NewSpark’s media pipeline have two paths for getting files into the system:

  1. Direct Upload URL — perfect for small files.
  2. Multipart Upload — designed for large files, letting you upload in chunks.

Both approaches ultimately tie back to NewSpark’s media service, and both must end with a call to media.uploadCompleted to finalize the file and make it available inside the platform.

This article walks through each workflow in practical, implementation-ready detail.

1. Uploading Small Files Using getUploadURL

When your file is comfortably below roughly 50MB (or any limit your application chooses), the simplest method is to request a secure, one-time upload URL.

API documentation:
https://documentation.newspark.io/apis/media/getUploadURL/

axios.post('/services/json', {
    method: "media.getUploadUrl",
    vhost: "YOUR_VHOST",
    fileData: {
        filename: file.name,
        filesize: file.size,
        extension: file.name.split('.').pop(),
        contenttype: file.type,
        title: "Optional Title",
        message: "Optional message",
        injector: "myuploader",
        tags: [],
        groupid: 0,
        channel: 0,
        metadata: { user: {'metakey':'metavalue'} },
        parentid: 0,
        uid: 0
    },
    v2: 1
}).then(response => {
    const uploadUrl = response.data.result.url;
    const mediaId = response.data.result.id;
});

NewSpark returns two important values:

• upload_url — temporary signed URL
• media_id — the internal ID you will finalize after upload

Step 2 — Upload the File to the URL

await axios.put(uploadUrl, file);

Step 3 — Finalize the Upload

axios.post('/services/json', {
     method: "media.uploadCompleted",
     id: mediaId
});

2. Multipart Uploads for Large Media

Large uploads such as HD video or large images require chunked uploads.
Multipart uploads are more reliable for large or unstable networks.

APIs involved:

Create Multipart:
https://documentation.newspark.io/apis/media/createMultiPartUpload/
Complete Multipart

https://documentation.newspark.io/apis/media/completeMultiPartUpload

Multipart Upload Example

axios.post('/services/json', {
    method: "media.createMultiPartUpload",
    vhost: "YOUR_VHOST",
    filename: file.name,
    contentType: file.type,
    filesize: file.size,
    partInfo: { 1: chunkSize, 2: chunkSize /* etc */ },
    timeOut: 10000,
    fileData: { title: "Optional", message: "Optional", injector: "uv3chunk" }
}).then(response => {
    const mediaId = response.data.result.id;
    const urls = response.data.result.partUrls;

    // Upload each chunk using its URL
    urls.forEach((part, index) => {
        const start = index * chunkSize;
        const blob = file.slice(start, start + chunkSize);
        axios.put(part.url, blob);
    });

    // 4. Complete the multipart upload
    axios.post('/services/json', {
        method: "media.completeMultiPartUpload",
        vhost: "YOUR_VHOST",
        filesize: file.size,
        id: mediaId
    }).then(res => console.log("Upload complete"));
});

// 5. Abort a multipart upload if needed
axios.post('/services/json', {
    method: "media.abortMultiPartUpload",
    vhost: "YOUR_VHOST",
    id: mediaId
}).then(res => console.log("Upload aborted"));


Summary: Choosing the Right Upload Method

• Small files: use media.getUploadURL
• Large files: use multipart (create → upload parts → complete)

This gives you a reliable, scalable workflow for uploading any type of media into the NewSpark platform.