---
title: "Upload Object"
url: https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/stratus/upload-object/
description: "This page describes the method to execute circuits in your application with sample code snippets."
last_updated: 2026-09-09T10:45:38Z
service: CloudScale
type: general
related_links:
- name: "Catalyst CloudScale"
url: /en/cloud-scale/
- name: "Stratus Help Documentation"
url: /en/cloud-scale/help/stratus/introduction/
- name: "Java SDK Documentation"
url: /en/sdk/java/v1/cloud-scale/stratus/upload-object/
- name: "Python SDK Documentation"
url: /en/sdk/python/v1/cloud-scale/stratus/upload-object/
- name: "iOS SDK Documentation"
url: /en/sdk/ios/v2/cloud-scale/stratus/upload-object/
- name: "Android SDK Documentation"
url: /en/sdk/android/v2/cloud-scale/stratus/upload-object/
- name: "Flutter SDK Documentation"
url: /en/sdk/flutter/v2/cloud-scale/stratus/upload-object/
- name: "REST API Documentation"
url: /en/api/code-reference/cloud-scale/stratus/upload-object/#UploadObject
repository:
name: "Repository"
url: https://github.com/catalystbyzoho/zcatalyst-sdk-js
---
# Upload Object
> **Note:** Ensure you have installed the [required package](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/stratus/overview/#prerequisites) to use this SDK method.
The SDK methods listed in this section will allow you to [upload objects](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/objects/upload-object/) to the [bucket](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/buckets/name-bucket/) in various manners. You can upload objects as a **string** or as a **stream**. The `bucket` reference used in the following code snippet is the [component instance](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/stratus/create-bucket-instance/).
If you do not have [Versioning](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/stratus-config/general-settings/#versioning) enabled for your object, and if Stratus gets multiple write requests for the same object, the object will be continuously overwritten. The latest upload of the object will be the only object that is stored.
However, with Versioning enabled, each upload will be considered a version of the object, and all of them will be stored in the bucket, each with a unique `versionId`.
> **Note:** The following characters including space are not supported when you create a path or an object: *double quote*, *both angular brackets*, *hashtag*, *backward slash*, and *pipe symbol*.
### Upload Object as a Stream
Using the `putObject()` SDK method in the following manner, you can upload objects to a bucket as a stream. Store the stream in a variable and then pass that variable in the upload method; `putObject()`
```javascript
// create a read stream for upload the object
const file = fs.createReadStream("file_path");
// call the upload method
await bucket.putObject("sam/out/sample.txt", file);
```
### Upload Object as a String
Using the `putObject()` SDK method in the following manner, you can upload the object as a string.
You will pass the object name, and the data to be stored in the object in string format to the upload method; `putObject()`
```javascript
// Upload object as a string
await bucket.putObject("sam/out/sample.txt", "Content of the file");
```
### Upload Object with Options
Using the `putObject()` SDK method in the following manner, you can use the following options while you upload an object.
* `overwrite`: This is an option you can use if *Versioning* for your bucket is not enabled for your bucket. Without versioning, you need to use this option if you wish to overwrite a resource. The default value is '**false**'.
* `ttl`: This is an option you can use to set **Time-to-Live** (TTL) in seconds for an object. Value should be greater than or equal to **60 seconds**.
* `metaData`: This is an option you can use to upload [meta details](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/objects/introduction/#metadata) of the object that is being uploaded.
* `contentType`: This is an option you can provide, if you need to set the MIME type of the object.
```javascript
const options = {
'overwrite': true, //This will overwrite your existing object
'ttl': '300', //time to live in seconds
'metaData': {
'author': 'John'
}
};
const file = fs.createReadStream("filePath");
await bucket.putObject("sam/out/sample.txt", file, options);
```
### Upload Object With Extract Option
When you upload a zipped object using the `putObject()` SDK method in the following manner, the objects present in the zip will be extracted and uploaded.
```javascript
const options = {
'ttl': '300', //time to live in seconds
'metaData': {
'author': 'John'
},
// Extract the contents of the given ZIP file and upload each file as a separate object to the bucket
'extractUpload': true
};
const file = fs.createReadStream("filePath");
await bucket.putObject("sam/out/sample.zip", file, options);
```
### Upload Object Using Multipart Utility
In this section we are going to go over the SDK methods that will allow you to successfully upload a large object to a bucket in Stratus.
The multipart upload utility will upload a large file to the bucket in multiple HTTPS requests. All of these requests will be combined into a single object once all the individual parts have been uploaded.
> **Note:** It is recommended that you consider **Multipart Upload** as the preferred method to upload objects that are **100 MB or larger**.
#### Initiate Upload
To perform multipart operations, you need to get a multipart object instance. You will refer to this component instance in various code snippets where you work with multipart operations being performed on objects stored in a bucket in Stratus.
#### Parameters Used
| Parameter Name |
Data Type |
Definition |
| `bucket` |
**SDK Instance** |
The `bucket` reference used in the following code snippet is the [component instance](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/stratus/create-bucket-instance/). |
```javascript
const initRes = await bucket.initiateMultipartUpload("sam/out/sample.txt");
console.log(initRes);
```
#### Example of Expected Response
```json
{
"bucket": "zcstratus123-development",
"key": "sam/out/sample.txt",
"upload_id": "01j7xbm4vm5750zbedxqgc4q6m",
"status": "PENDING"
}
```
#### Upload Parts of the Object
The following code snippet illustrates the manner in which you can perform uploads of the individual parts of the object.
Each part will have a distinct `partNumber` ranging anywhere between **1** and **1000**. While this represents the ordering of the parts, these parts will not necessarily be uploaded in sequence. These parts will be combined in sequence once the upload of all the parts of the objects is complete.
```javascript
const partNumber = 1;
const file = fs.createReadStream("filePath");
await bucket.uploadPart("sam/out/sample.txt", "uploadId", file, partNumber);
```
#### Get Multipart Upload Summary
The following example code snippet demonstrates the manner in which you can use the `getMultipartUploadSummary()` SDK method to obtain an operational summary of all the uploaded parts.
```javascript
const uploadSummaryRes = await bucket.getMultipartUploadSummary("sam/out/sample.txt", "upload_id");
console.log(uploadSummaryRes);
```
#### Example of Expected Response
```javascript
{
"bucket": "zcstratus12345-development",
"key": "sam/out/sample.txt",
"upload_id": "01hyfyeazrrstmt7k5fa7ej726",
"status": "PENDING",
"parts": [
{
"part_number": 1,
"size": 0,
"uploaded_at": 1716374678999
},
{
"part_number": 2,
"size": 2797094,
"uploaded_at": 1716374678576
},
{
"part_number": 4,
"size": 0,
"uploaded_at": 1716374679136
}
]
}
```
#### Complete Multipart Upload of the Object
The following example code snippet demonstrates the manner in which you can terminate the multipart process once all the parts have been successfully uploaded.
To complete the process, you will need to pass the `uploadId` to the `completeMultipartUpload()` method.
#### Example Code Snippet Implementing Multipart Upload
```javascript
const fs = require('fs');
module.exports = async (req, res) => {
url = req.url;
switch (url) {
case '/':
const auth = new ZCAuth();
const authInit = await auth.init(req);
const stratus = new Stratus();
/** create a bucket instance */
const bucket = stratus.bucket("bucket_name");
/** multipart upload */
const key = 'sample.mp4';
// initiate multipart upload
const initRes = await bucket.initiateMultipartUpload(key);
// get upload Id from initiate upload response.
const uploadId = initRes['upload_id'];
const filePath = '/Users/Aliza//sam.mp4';
const partSize = 50 * 1024 * 1024; // in Mb
const fileStream = fs.createReadStream(
filePath,
{ highWaterMark: partSize }
);
let partNumber = 1;
const uploadPromises = [];
fileStream.on('data', async (partData) => {
// Push each part upload to the promises array for parallel upload
const partUploadPromise = bucket.uploadPart(
key,
uploadId,
partData,
partNumber
);
uploadPromises.push(partUploadPromise);
console.log('Part Number: ', partNumber);
partNumber++;
});
// Wait for all parts to be uploaded in parallel
fileStream.on('end', async () => {
await Promise.all(uploadPromises);
// Complete the multipart upload
await bucket.completeMultipartUpload(key, uploadId);
console.log('Successfully Uploaded');
});
res.end();
break;
default:
res.writeHead(404);
res.write('You might find the page you are looking for at "/" path');
break;
}
}
```
### Upload an Object Using the Transfer Manager Utility
#### Create Transfer Manager Instance
```javascript
const transferManager = new TransferManager(bucket); // create transfer manager instance
```
### Multipart Upload
#### Create Multipart Upload Instance
The following code snippet will create a multipart instance to initiate multipart upload.
```javascript
const multipart = await transferManager.createMultipartInstance("sam/out/sample.txt"); // create multipart instance
```
If you are required to create an instance for an already initialized multipart upload operation, then copy and use the code snippet given below.
```javascript
const multipart = await transferManager.createMultipartInstance("sam/out/sample.txt", "uploadId");
```
#### Upload Parts of the Object
In the following example code snippet, you need to initialize a multipart instance, as defined in the [Create Multipart Upload Instance section](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/stratus/upload-object/#upload-an-object-using-the-transfer-manager-utility).
With this instance, you can use the `uploadPart()` SDK method to upload parts of the object.
```javascript
await multipart.uploadPart(fs.createReadStream("filePath"), partNumber);
```
#### Upload Summary
The following code snippet demonstrates the use of the `getUploadSummary()` SDK method to get a summary of the upload process.
```javascript
const summaryRes = await multipart.getUploadSummary();
console.log(summaryRes);
```
#### Complete Upload
The following code snippet demonstrates the use of the `completeUpload()` SDK method to complete the upload process.
```javascript
await multipart.completeUpload();
```
#### Upload Object Using Wrapper
The following code snippet demonstrates the use of the `putObjectAsParts()` SDK method acts as a wrapper, where the entire multipart upload operation is carried out without employing multiple steps.
Using this method, the object is split into multiple parts, uploaded to the bucket in multiple parts, and then combined once all the parts are uploaded.
```javascript
const file = fs.createReadStream("filePath");
const partSize = 50 // in MB
const objectPartUploadRes = await transferManager.putObjectAsParts("sam/out/sample.txt",file, partSize);
console.log(objectPartUploadRes);
```
### Generate Presigned URL to Upload an Object
> **Info:** To use this SDK method, you need to initialize it with **Admin** scope. You can learn more about this requirement from this [section](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/scopes/).
Presigned URLs are secure URLs that authenticated users can share with their non-authenticated users. This URL will provide non-authenticated users with temporary authorization to access objects.
The `bucket` reference used in the following code snippet is the [component instance](https://docs.catalyst.zoho.com/en/sdk/javascript/v1/cloudscale/stratus/create-bucket-instance/).
#### Parameters Used
| Parameter Name |
Data Type |
Definition |
| `key` |
**String** |
A **mandatory** parameter. Will hold the complete name of the object along with its [path](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/objects/introduction/#path). |
| `urlAction` |
**Request Method** |
A **mandatory** parameter. This is the parameter that will allow you to generate a presigned URL for an upload (`PUT`) action.
- `PUT`: To upload an object.
|
| `expiry` |
**String** |
This is an **optional** parameter. The URL validity time in seconds.
- Default value: **3600 seconds**
- Minimum value: **30 seconds**
- Maximum value: **7 days**
|
| `activeFrom` |
**String** |
This is an **optional** parameter. This parameter will contain the time after which the URL is valid.
- Maximum value: **7 days**
URLs are made active as soon as they are generated by default.
|
```javascript
const signedURLRes = await bucket.generatePreSignedUrl("sam/out/sample.txt", 'PUT', {
'expiryIn': 100, // expiry time in seconds
'activeFrom':'12334454327', // activate the url in the given date
});
console.log(signedURLRes);
```
#### Example mof Expected Response
```javascript
{
signature: "https://sadi-development.zohostratus.com/_signed/text.txt?organizationId=96862383&stsCredential=96858154-96862383&stsDate=1747896279887&stsExpiresAfter=300&stsSignedHeaders=host&stsSignature=3YBUX1HFSxNQzQJjFrln82AyJsEEuC5T9dsZwWxGyEE"
}
```
#### Example Code Snippet: Upload with Presigned URL
> **Info:** This example is shown using **Axios** request handler package.
```javascript
const axios = require('axios');
const fs = require('fs');
// Replace this with the actual pre-signed URL generated for your upload.
const url = ‘https: //sadi-development.zohostratus.com/_signed/text.txt?organizationId=96862383&stsCredential=96858154-96862383&stsDate=1747911331272&stsExpiresAfter=300&stsSignedHeaders=host&stsSignature=K9vuqC7JaATLeM3TX4xXWx0OHcSflbYQ2jCrbKSAAIE';
// Replace ‘file_path’ with your actual file path
const data = fs.createReadStream(’/Users/amelia - 426 / Documents / JavaScript - SDK / Stratus / sam.py’);
// Optional headers; content type may vary depending on the file type
const headers = {
// ‘Content-Type’: ‘application/json’, // adjust if uploading non-JSON files (e.g., ’text/plain’ or ‘application/octet-stream’)
// ‘overwrite’: ’true’, // optional header
};
(async () => {
try {
const response = await axios.put(url, data, {
headers
});
if (response.status === 200) {
console.log('Object uploaded successfully');
} else {
console.log('⚠️ Error uploading object:', response.data);
}
} catch (error) {
console.error('Upload failed:', error.response?.data || error.message);
}
})();
```