-
-
Notifications
You must be signed in to change notification settings - Fork 169
addFile
dr.dimitru edited this page Jul 22, 2018
·
7 revisions
Add local file to FilesCollection from FS.
Note: You can not use this method on public
collections. As they supposed to be served without NodeJS (Meteor) participation. But you always can move file to root of your web-server and then add a record to FilesCollection.
-
path
{String} - Full path to file, like/var/www/files/sample.png
-
opts
{Object} - Recommended properties:-
opts.fileName
{String} - File name with extension, likename.ext
-
opts.meta
{Object} - Object with custom meta-data -
opts.type
{String} - Mime-type, likeimage/png
-
opts.size
{Number} - File size in bytes, if not set - size will be calculated from file -
opts.userId
{String} - UserId, default null -
opts.fileId
{String} - _id of inserted file, if not set - Random.id() will be used
-
-
callback
{Function} - Triggered after new record is added to Collection. Witherror
, andfileRef
, wherefileRef
is a new record from DB - proceedAfterUpload {Boolean} - Proceed
onAfterUpload
hook (if defined) after local file is added toFilesCollection
- Returns {FilesCollection} - Current FilesCollection instance
import { FilesCollection } from 'meteor/ostrio:files';
const Images = new FilesCollection({collectionName: 'Images'});
Images.addFile('/var/www/files/sample.png', {
fileName: 'sample.png',
type: 'image/png',
fileId: 'abc123AwesomeId',
meta: {}
});
Meteor-Files | Support | Try ostr.io |
---|---|---|
If you found this package useful, — star it at GitHub and support our open source contributions with a monthly pledge, or submit a one-time donation via PayPal | Monitoring, Analytics, WebSec, Web-CRON and Pre-rendering for a website |