Open Nits7029 opened 9 years ago
+1
I don't see any difference in 1) and 2) but you might want to check your collection filters and make sure you accept the right content types, in your case binary/octet-stream
.
var imageStore = new FS.Store.GridFS("images", {});
Images = new FS.Collection("images", {
stores: [imageStore],
filter: {
maxSize: 1048576, // in bytes
allow: {
contentTypes: ['binary/octet-stream'], // <<<<------------------
extensions: ['png']
},
deny: {
contentTypes: [],
extensions: []
},
onInvalid: function (message) {
console.log(message);
}
}
});
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
var newFile = new FS.File();
newFile.attachData("https://d3kjp0zrek7zit.cloudfront.net/uploads/product/image/4533/large_detail_1410557285.png", function(error) {
console.log(error);
newFile.name("test.png");
Images.insert(newFile, function(error, fileObj) {
console.log(error, fileObj);
});
});
});
}
Thanks for you reply, I really appreciate it.
One more thing, but in my case content type will be "image" or "binary/octet-stream"
So how to allow multiple content type in configuration.
Thanks.
is it something like ['image/*', 'binary/octet-stream'] ?
yes, but the link you provided is a binary/octet-stream
.
ok, but i have lots of image URLs and I don't all images content type, that's why.
One more thing.
My site is running on http, so can i store images which are from https.
I run you code and it's giving me a below error:
timeout and Error: FS.Collection insert: file does not pass collection filters.
Hello,
I am fetching images in bulk from external URL, but from some of URLs images are downloading directly, I think it's content-type is attachment so. below is the code that I am using
1) code is working fine
2) getting error - Error: FS.Collection insert: file does not pass collection filters https://d3kjp0zrek7zit.cloudfront.net/uploads/product/image/4533/large_detail_1410557285.png has attachment content type.
Please help