You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Images.insert(url,function(error,fileObj){//If !error, we have inserted new doc with ID fileObj._id, and//remote URL data will be downloaded and stored on the server. The//URL must support a HEAD request since we do one to get the //content type, size, etc. for filtering inserts.});
On the server, you can omit the callback and the method will block until the
data download and insert are both complete. Then it will return the new FS.File
instance.
varnewFileObj=Images.insert(url);
On the client, you can omit the callback if you don't need to
access the resulting FS.File instance, and any errors will be thrown.
When you pass a URL directly to insert, the filename will be extracted
from the end of the URL string, but only if it ends with an extension. Otherwise
filename will be null. If you want to avoid a null filename, you will have to
explicitly attach the URL to a new FS.File instance and set the name:
varnewFile=newFS.File();newFile.attachData(url,function(error){if(error)throwerror;newFile.name("newImage.png");Images.insert(newFile,function(error,fileObj){//If !error, we have inserted new doc with ID fileObj._id, and//remote URL data will be downloaded and stored on the server. The//URL must support a HEAD request since we do one to get the //content type, size, etc. for filtering inserts.});});