--- title: "Download Object" url: https://docs.catalyst.zoho.com/en/sdk/java/v1/cloud-scale/stratus/download-object/ description: "This page lists the Java SDK method to download objects from a bucket." last_updated: 2026-09-08T11:07:33Z service: Cloud Scale type: general related_links: - name: "Stratus Component Help Documentation" url: /en/cloud-scale/help/stratus/introduction - name: "Download Object Help Documentation" url: /en/cloud-scale/help/stratus/objects/manage-object/download-object/ - name: "JavaScript SDK Documentation" url: /en/sdk/javascript/v1/cloudscale/stratus/download-object/ - name: "Python SDK" url: /en/sdk/python/v1/cloud-scale/stratus/download-object/ - name: "iOS SDK" url: /en/sdk/ios/v2/cloud-scale/stratus/download-object/ - name: "Android SDK" url: /en/sdk/android/v2/cloud-scale/stratus/download-object/ - name: "Flutter SDK" url: /en/sdk/flutter/v2/cloud-scale/stratus/download-object/ - name: "REST API" url: /en/api/code-reference/cloud-scale/stratus/get-all-buckets/#GetAllBuckets --- # Download Object The SDKs present in the section will allow you to [download a particular object](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/objects/manage-object/download-object/), or version of the object. The Bucket reference used in the below code snippet is the [component instance](https://docs.catalyst.zoho.com/en/sdk/java/v1/cloud-scale/stratus/create-bucket-instance/). The first step of the download operation is a `GET` operation that retrieves the required object from the bucket. To be able to download an object, the requester must have `READ` access permissions. However, owners of the bucket do have the option to grant `READ` access permissions to users, allowing them to download the object without using the required response headers. If [Versioning](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/stratus-config/general-settings/#versioning) is enabled for your bucket, you need to pass the `versionId` to download the particular version of the object. If no `versionId` is passed, then by default, the latest version of the object will be downloaded. If *Versioning* was enabled for a bucket, then disabled. By default, the principal first object will be downloaded. To ensure you download the latest version of this object, you need to pass the `versionId` param with the value "`topVersion`". #### Sample Code Snippet **Package Imports** ```java import java.nio.file.Path; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.io.*; ``` ```java InputStream dataStream = bucket.getObject("sam/out/sample.txt"); // download the object to your local machine Path path = Path.of("file_path"); // specify a path to store the downloaded object Files.copy(dataStream, path, StandardCopyOption.REPLACE_EXISTING); ``` ### Download a Portion of the Object The following SDK implements the `setRange()` method. This method allows you to download a specific range of bytes of an object. #### Sample Code Snippet **Package Imports** ```java import com.zc.component.stratus.beans.ZCGetObjectOptions; import java.nio.file.Path; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.io.*; ``` ```java // add download options ZCGetObjectOptions options = ZCGetObjectOptions.getInstance(); options.setVersionId("3yt5ehjbjghds3i28"); options.setRange("20-200"); // start and end range of the object in bytes InputStream dataStream = bucket.getObject("sam/out/sample.txt", options); // download the object to your local machine Path path = Path.of("file_path"); // specify a path to store the downloaded object Files.copy(dataStream, path, StandardCopyOption.REPLACE_EXISTING); ``` ### Download an Object Using Transfer Manager In this section, we are going to go over SDK methods that will allow you to successfully download large objects from Stratus to your local system using **Transfer Manager** technique. Transfer Manager is an operation where the large object is split into multiple byte ranges using the start and end bytes range of the object. Each of the object's parts is then returned as a stream, and they are downloaded to your local system. #### Create Transfer Manager Instance #### Sample Code Snippet **Package Imports** ```java import com.zc.component.stratus.transfer.ZCTransferManager; ``` ```java ZCTransferManager transferManager= ZCTransferManager.getInstance(bucket); ``` #### Download Object as Iterable Part Streams #### Sample Code Snippet **Package Imports** ```java import java.nio.file.StandardOpenOption; import java.nio.file.Files; import java.util.Iterator; import java.nio.file.Path; import java.io.*; ``` ```java Iterable <InputStream> Iterable = transferManager.getIterableObject("sam/out/sample.txt", 100 L); Path path = Path.of("file_path"); Iterator <InputStream> res = Iterable.iterator(); while (res.hasNext()) { InputStream data = res.next(); // get each part of the object as stream Files.copy(data, path, StandardCopyOption.REPLACE_EXISTING); // write the stream to local file path } ``` #### Generate Object Parts for Download In this SDK method we will download a portion of the object that falls under the required start and end range of bytes. **Parameters Used** * `PartSize`: It is the size of each part in Mb * `key`: Will hold the name of the object #### Sample Code Snippet **Package Imports** ```java import java.nio.file.StandardOpenOption; import java.nio.file.Files; import com.zc.component.stratus.beans.ZCStratusGetObject; import java.nio.file.Path; import java.io.*; ``` ```java Path path = Path.of("file_path"); // get the list of part functions List<ZCStratusGetObject> parts = transferManager.generatePartDownloaders("sam/out/sample.txt", 100L); // create a file to store the downloaded stream. Files.createFile(path); int partNumber = 1; // trigger the each function to download the object parts for (ZCStratusGetObject part : parts) { // get object part as stream InputStream inputStream = part.getPart(); System.out.println("Part "+ partNumber++ + " Downloaded"); // write the stream data to local machine Files.write(path, inputStream.readAllBytes(), StandardOpenOption.APPEND); } ``` ### Generate Presigned URL to Download an Object Presigned URLs are secure URLs that authenticated users can share to their non-authenticated users. This URL will provide non-authenticated users with temporary authorization to access objects. The Bucket reference used in the below code snippet is the [component instance](https://docs.catalyst.zoho.com/en/sdk/java/v1/cloud-scale/stratus/create-bucket-instance/). > **Info:** To use this SDK method, you need intialize it with **Admin** scope. You can learn more about this requirement from this [section](https://docs.catalyst.zoho.com/en/sdk/nodejs/v2/overview/#initialize-sdk-with-scopes) **Parameters Used**
Parameter Name Data Type Definition
`key` **String** A **Mandatory** parameter. Will hold the complete name of the object along with it's [path](https://docs.catalyst.zoho.com/en/cloud-scale/help/stratus/objects/introduction/#path).
`URL_ACTION` **Enum** A **Mandatory** parameter. This is the parameter that will allow you to generate a presigned URL for download action.
  • `URL_ACTION.GET`: To download 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 param will contain the time after which the URL is valid. Maximum value is **7 days**. URLs are made active as soon as they are generated by default.
#### Sample Code Snippet **Package Imports** ```java import com.zc.component.stratus.enums.URL_ACTION; import org.json.simple.JSONObject; ``` ```java JSONObject res = bucket.generatePreSignedUrl("sam/out/sample.txt",URL_ACTION.GET); System.out.println(res.get("signature")); ``` ### Generate Presigned URL With Expiry and Active Time #### Sample Code Snippet **Package Imports** ```java import com.zc.component.stratus.enums.URL_ACTION; import org.json.simple.JSONObject; ``` ```java JSONObject res = bucket.generatePreSignedUrl("object_name",URL_ACTION.GET, "expiry_in","active_from"); System.out.println(res.get("signature")); ``` **Example Response for Generating a Presigned URL for Download** ```json { signature: 'https://sadi-development.zoho stratus.com/_signed/text.txt?organizationId=96862383&stsCredential=96858154-96862383&stsDate=1747896279887&stsExpiresAfter=300&stsSignedHeaders=host&stsSignature=3YBUX1HFSxNQzQJjFrln82AyJsEEuC5T9dsZwWxGyEE' } ``` **Example Snippet Illustrating Usage of Presigned URL to Upload an Object** **Package Imports** ```java import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; ``` ```java public class Download { public static void main(String[] args) throws IOException { // Create an OkHttpClient instance to handle the HTTP request OkHttpClient client = new OkHttpClient(); // Build the GET request with the pre-signed URL Request request1 = new Request.Builder() .url("https://sadi-development.zohostratus.com/_signed/sam.txt?organizationId=96862383&stsCredential=96858154-96862383&stsDate=1747905744487&stsExpiresAfter=300&stsSignedHeaders=host&stsSignature=pCjV9xckDOqBCueE_gBeMbp12StddTghBK_8HUwU5k0") // Replace with your actual URL .build(); // Execute the request and handle the response try (Response response1 = client.newCall(request1).execute()) { // Check if the response was successful if (!response1.isSuccessful()) { throw new IOException("Unexpected code " + response1); } // Get the response body as an InputStream ResponseBody body = response1.body(); if (body != null) { // Create a stream to write the file to disk try (InputStream in = body.byteStream(); OutputStream out = new FileOutputStream("file_path")) { // Replace file_path with the actual path // Read the response data in chunks and write to the file byte[] buffer = new byte[8192]; int len; while ((len = in.read(buffer)) != -1) { out.write(buffer, 0, len); } // Print confirmation after successful download System.out.println("Download complete."); } } } catch (IOException e) { // Print stack trace if an error occurs during the download e.printStackTrace(); } } } ```