Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9159] Ti API: Easier way to convert between Blobs and Buffers

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 1.8.0
Fix Version/sn/a
ComponentsTiAPI
Labelsn/a
ReporterArthur Evans
AssigneeUnknown
Created2012-05-16T16:34:03.000+0000
Updated2018-02-28T20:04:07.000+0000

Description

To go from a Buffer to a Blob we have Buffer.toBlob. However, there's no matching Blob.toBuffer. This would be handy since Buffers are more easily mutable than blobs, and some methods only accept one type or the other. I think the current workaround for Blob > Buffer is something like:
var blobStream = Ti.Stream.createStream({ source: myBlob, mode: Ti.Stream.MODE_READ });
var newBuffer = Ti.createBuffer({ length: myBlob.length });
var bytes = blobStream.read(newBuffer);
This is muy ugly. It seems like it would be a lot simpler to add support for creating a buffer from a Blob in Ti.createBuffer:
var buffer = Ti.createBuffer({ value: myBlob });

Comments

No comments

JSON Source