Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions meteor-file-uploader.js

This file was deleted.

28 changes: 28 additions & 0 deletions meteor-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,35 @@ EJSON.addType("MeteorFile", MeteorFile.fromJSONValue);

/************************ Client *********************************************/
if (Meteor.isClient) {

/**
* Create a binary string out of an array of numbers (bytes), each varying
* from 0-255.
*
* @param {Array} bytes The array of numbers to transform into a binary str.
* @return {string} The byte array as a string.
*/
function arrayToBinaryString(bytes) {
if (typeof bytes != typeof []) {
return null;
}
var i = bytes.length;
var bstr = new Array(i);
while (i--) {
bstr[i] = String.fromCharCode(bytes[i]);
}
return bstr.join('');
}

function toDataURL(contentType, uint8Array) {
return 'data:' + contentType + ';base64,' +
self.btoa(arrayToBinaryString(uint8Array));
}

_.extend(MeteorFile.prototype, {
getDataUrl: function() {
return toDataURL(this.type, this.data);
},
read: function (file, options, callback) {
if (arguments.length == 2)
callback = options;
Expand Down
2 changes: 0 additions & 2 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ Package.describe({

Package.on_use(function (api) {
api.use(["underscore", "ejson"], ["client", "server"]);
api.use(["handlebars", "spark"], "client");
api.add_files(["meteor-file.js"], ["client", "server"]);
api.add_files("meteor-file-uploader.js", "client");

if (typeof api.export !== 'undefined') {
api.export("MeteorFile", ["client", "server"]);
Expand Down