Skip to content
This repository has been archived by the owner on Mar 14, 2019. It is now read-only.

Server-side Inserts Don't Work #246

Closed
aldeed opened this issue Apr 3, 2014 · 3 comments
Closed

Server-side Inserts Don't Work #246

aldeed opened this issue Apr 3, 2014 · 3 comments

Comments

@aldeed
Copy link
Contributor

aldeed commented Apr 3, 2014

@raix, I spent some time trying to debug this, but I can't figure it out. When you do a server side insert of filepath or URL, there is a RangeError stack size exceeded error. It's something within the tempstore writestream code (I think), but I don't know what. It must be something different about the internal: true code because it doesn't happen when streaming to a normal store (or when chunks are coming over from the client).

Running this on the server, you will see it:

Images.insert("http://cdn.morguefile.com/imageData/public/files/b/bboomerindenial/preview/fldr_2009_04_01/file3301238617907.jpg");

It doesn't matter what SAs you use because it never gets that far. The file appears for a second in the _tempstore but then disappears and 'stored' never fires.

@aldeed
Copy link
Contributor Author

aldeed commented Apr 7, 2014

I think this fixed itself. :)

@aldeed aldeed closed this as completed Apr 7, 2014
@digz6666
Copy link

digz6666 commented Aug 7, 2015

I'm getting this error when I store FS.File reference to collection.

RangeError: Maximum call stack size exceeded

I created FS.File from base64 buffer using following code:

var post = Post.find({id: postId});

var dataUrlRegExp = /^data:image\/\w+;base64,/;

for (var i in images) {
    var imageBuffer = new Buffer(images[i]['data'].replace(dataUrlRegExp, ""), "base64");
    var newFile = new FS.File();
    newFile.attachData(imageBuffer, {type: 'image/png'}, function(error){
        if(error) throw error;
        newFile.name(images[i]['dataId'] + '.png');
        Images.insert(newFile, function(err, fileObj) {
            if (err == null) {
                Post.update({ _id: postId },{ $push: { images: fileObj }})
            }
        });
    });
}

Images and Post declaration.

var imageStore = new FS.Store.FileSystem("images", { path: "~/uploads/images" });

Images = new FS.Collection("images", {
    stores: [
        imageStore
    ],
    filter: {
        allow: {
            maxSize: 3145728, // max file size 3MB
            contentTypes: ['image/*'] // allow only images in this FS.Collection
        }
    }
});

Post = new Mongo.Collection('posts');

If I store image id to images property of the Post collection, it works fine. But I have to store the FS.File reference to get the URL easily.

@digz6666
Copy link

digz6666 commented Aug 7, 2015

Ah I had to install cfs:ejson-file package, my issue is resolved :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants