Skip to main content
16-Pearl
April 30, 2026
Question

Uploading Multiple Large Images (≈130 MB total) via REST API to FileRepository

  • April 30, 2026
  • 3 replies
  • 54 views

 

 

Hi everyone,

I’m currently working on a use case in ThingWorx and would appreciate some guidance.

Use case:

  • We have a FileRepository (connected to a File Share) where we store images.

  • A customer wants to send 6 images via REST API, each around 25 MB.

  • Total payload per request would be roughly 130–150 MB.

  • After receiving the images, I need to:

    • Store them in the FileRepository

    • Save the path in a DataTable for later access

Challenge:

  • Sending images as Base64 in JSON would significantly increase payload size (~30% overhead).

  • The customer prefers to send all images in a single request, not one by one.

  • I’m unsure about the best approach in ThingWorx for handling such large payloads reliably (timeouts, limits, performance, etc.).

Questions:

  1. What is the recommended approach for handling multiple large file uploads in ThingWorx via REST?

  2. Is it better to:

    • Accept a ZIP file (Base64) and extract it server-side?

    • Use multipart/form-data (if supported properly)?

    • Or enforce multiple smaller requests (one image per call)?

  3. Are there any size limits or best practices regarding REST payloads and FileRepository uploads?

Would really appreciate insights or examples from anyone who has handled similar large file upload scenarios.

Thanks in advance!

3 replies

16-Pearl
May 5, 2026

Upload via FileUploadWidget-API / Composer File upload API:

  • He could upload them as binary directly into the file repository. You can check what request the FileUploadWidget in a mashup does to upload binary and recreate it.
  • Size limit is not restricted via the FileUploadWidget-API by TWX. Only nginx-proxy (if you are cloud hosted or kubernetes) has some set limit (which can be modified).
  • But unfortunate for uploads done like this there is no Event fired
    • You could regularly scan the directory with a scheduler to extract the .zip files (if he only wants one upload) or check if there are new files to process.

Upload via service call with bas64 encoding might cause memory issues.

MA873117416-PearlAuthor
16-Pearl
May 6, 2026

Thanks ​@nmutter for your reply. I have prepared two rest APIs to send the image file into fileRepository

 

SaveImage Service: This service expects Base64 image in order to save it into file repository which is not that ideal.

 

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const fs = require("fs");
const axios = require("axios");
const username = "username";
const password = "password";



const url = "https://server.com:8443/Thingworx/Things/test.FileRepository.Connector/Services/SaveImage";



async function uploadImage() {
try {
// Read image file
const fileBuffer = fs.readFileSync("C:/Users/23442/Desktop/images.jpg");

// Convert to Base64
const base64Image = fileBuffer.toString("base64");

// Prepare JSON body
const payload = {
path: "/TestingAPIImage/nodeImage.jpg",
content: base64Image
};


const response = await axios.post(url, payload, {
headers: {
"Accept": "application/json",
"Content-Type": "application/json"

},
auth: {
username: username,
password: password
}
});

console.log("Status:", response.status);
console.log("Response:", response.data);

} catch (error) {
if (error.response && error.response.data) {
console.error("Error:", error.response.data);
} else {
console.error("Error:", error.message);
}
}
}

uploadImage();

 

FileRepositoryUploader: Which you have suggested is better because it uses multipart / form-data and store the file into File Repository

 

 

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const axios = require("axios");
const fs = require("fs");
const FormData = require("form-data");

const username = "username";
const password = "password";

const TWXURL = "https://server.com:8443/Thingworx";
const uploadUrl = `${TWXURL}/FileRepositoryUploader`;

async function uploadFile() {
try {
const form = new FormData();

form.append("upload-repository", "Test.FileRepository");
form.append("upload-path", "TestingAPIImage");
form.append("upload-submit", "Upload");

form.append("file", fs.createReadStream("C:/Users/4555/Desktop/images.zip"), {
filename: "/nodeImage.zip",
contentType: "image/jpeg"
});

const response = await axios.post(uploadUrl, form, {
headers: {
...form.getHeaders(),
Accept: "application/json",
"X-XSRF-TOKEN" : "TWX-XSRF-TOKEN-VALUE"
},
auth: {
username,
password
},
maxBodyLength: Infinity,
maxContentLength: Infinity
});

console.log("Status:", response.status);
console.log("Response:", response.data);
} catch (error) {
if (error.response && error.response.data) {
console.error("Error:", error.response.data);
} else {
console.error("Error:", error.message);
}
}
}

uploadFile();

 

 

So, these both services are working. Now i would confirm it with a customer that how he would send an images to our system. The plan is to send 6 images per request but if they wants to send 6 images then i would expect one zip file and if he sends one image then it would be fine too. 

If it would be zip file then i have to call another service also which would do unzip the file after being uploaded. I would do this manually like when i get status 200 then i would run another service to do unzip the files. would that be okay? 

 

Another Question: When i send a file bigger then 50 MB via SaveImage API then i get an error of limit which is good  to know that there is a limit but when i send a file bigger then 50 MB via FileUpload  then it keeps trying to fulfill the request but i get no error and then i have to stop it myself because it does not work even though i have waited 5 minutes. any idea about this behaviour?

 

and generally is it ok to send the data file via rest api which has size of around 130 MB? 

Rocko
19-Tanzanite
May 6, 2026

Side note: When you upload a zip your content-type is not ”image/jpeg”

MA873117416-PearlAuthor
16-Pearl
May 6, 2026

Results:

 

When i use saveImage service to save photo on remote repository it takes 4 seconds to save an image of 30 MB

but when i use FileRepositoryUploader service it takes around 4 minutes to store an image there. Any Idea? Why its like that?

16-Pearl
May 6, 2026

can you upload the same image via the compose filerepo-view (which uses the same service in the background). and see if this is faster? if it’s faster something with your manual request is off I guess

MA873117416-PearlAuthor
16-Pearl
May 6, 2026

@nmutter I have tried directly in the composer of this repository and unfortunatly the result is same. Its taking 5 minutes to upload the pic of 30 MB. What do you think is a reason? With SaveImage service its working in 4 seconds. For my other project i am using the repo also and already got a complaint that 5 mb of pdf file is even taking very long. But again the weired behaviour is saveimage service is very fast to upload. 

 

Just for info(i don think so that can be the reason)

In the composer when i click on repository then it does not load the folders to show whats already saved in it because this repository has a lot lot of data in it. its been 20 minutes still its bank . i cannot see any folder or hierarchy in the repository in the composer. 

Support
May 18, 2026

Hello ​@MA8731174 

 

I hope you’re doing well.

 

I’m following up on your post to check if there are any updates or if you need further assistance.

If any of the responses have helped resolve your question, please consider marking it as the “Best Answer”. Also, feel free to share any additional details or ask further questions to the community.

 

Thank you!

Abhi