Sometime while uploading large files we face many issues like out of memory error, timeout error etc. To get rid of these type of errors we should read file(blob) into chunks.
The BlobStream is a read-only stream that provides you with the ability to read blobs in chunks.
Here is an example:
Ti.Media.showCamera({
success: function(e) {
// Open stream on blob.
var instream = Titanium.Stream.createStream({
mode: Titanium.Stream.MODE_READ,
source: e.media // e.media is a Blob
});
// Create a buffer for chunking the data.
var buffer = Ti.createBuffer({length: 1024});
// Read and write chunks.
var read_bytes = 0;
while ((read_bytes = instream.read(buffer)) > 0) {
}
// Cleanup.
instream.close();
}
});
THANKS
More From Oodles
Mahipal Singh | 13-Dec-2024
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Sapna Sharma
Sapna is a bright Android Apps developer using Titanium framework. Sapna likes music and helping needy people.