Meteor-Community-Packages / Meteor-CollectionFS

Reactive file manager for Meteor
MIT License
1.05k stars 237 forks source link

CollectionFS doesn't work with Cordova #257

Open factualz opened 10 years ago

factualz commented 10 years ago

FS.Collection insert doesnt work when called from Cordova app (using any of the methdos https://github.com/SpaceCapsule/Meteor-cordova in iframe or https://github.com/zeroasterisk/MeteorRider). I am using GridFS as store. The insert call inserts a document in cfs.xxx.filerecord but fails to send the file chunks. The same code works beautfiully in web. Please check and fix as we are dependent on CollectionFS for production release plan.

var photoFile = Session.get('photoFile');
        if (photoFile && photoFile.dataUrl){
            var newFile = new FS.File({
                metadata: {serviceId: Session.get('serviceId')},
                size: photoFile.dataUrl.length,
                contentType: 'image/png',
                name: 'myphoto'
            });
            newFile.attachData(photoFile.dataUrl, function(err){
                if (!err){
                    Photos.insert(newFile, function(err, fileObj){
                        if (!err) {
                            taskSave({
                                from: Meteor.userId(),
                                type: 'photo',
                                info: $('#photoNote').val(),
                                photoId: fileObj._id
                            });
                        }
aldeed commented 10 years ago

I'm not sure if getting it to work with cordova is a priority before 1.0, but if you provide a reproduction repo, we can see if there's something simple.

A couple comments on your code: