Download an Object From a Bucket
To download an object from the bucket:
The object will be downloaded to your local system.
You can also download the object using the Download button present in the object details view.
Ensure the following packages are imported
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.*;
InputStream dataStream = bucket.getObject(“objectName”);
// 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);
const res = await bucket.getObject(“objectName”);
// download the object to local machine
const files = fs.createWriteStream(‘filePath’);
res.on(‘data’, (data) => {
files.write(data)
});
res = bucket.get_object(‘object_name’)
# download the object to local machine
file = open(‘file_path’,‘wb’)
file.write(res)
objectInstance.download(fromCache : true) {
result in switch result {
case.success(let url):
do {
let data = Data(contentsOf : url) DispatchQueue.main.sync {
self.imageView.image = UIImage(date : data)
}
}
catch {
print("Error : \( error )")
}
case.error(let error):
print("Error : \( error )")
}
}
bucketInstance.getObject("SunSet.jpeg", "2823000000044005", //Replace this with your Folder ID and File ID
{
object->object.download({println("File download success ${it.available()}")},
{println("File download failed $it")})
try {
ZCatalystBucket bucket = stratus.bucket("testing");
var(response, object) = await bucket.getObject("SunSet.jpeg");
final downloadsDir = await getExternalStorageDirectory();
final filePath = downloadsDir !.absolute.path;
var fileResponse = await object.download(
pathToDownload
: filePath, onProgress
: (bytesWritten, contentLength, percentage) {
print("Downloaded Percentage: $percentage");
}, );
print("Download Status: ${fileResponse.statusCode}");
OpenFile.open(filePath + '/SunSet.jpeg');
}
on ZCatalystException catch (ex) { print(ex.toString()); }
Last Updated 2025-07-02 15:43:56 +0530 IST
Yes
No
Send your feedback to us