I'm afraid I don't understand the documentation. This my initialization
export default Avatars = new FilesCollection({
collectionName: 'users.avatars',
storagePath: '/data',
allowClientCode: false, // Disallow remove files from Client
onBeforeUpload: function (file) {
// Allow upload files under 10MB, and only in png/jpg/jpeg formats
if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
return true;
} else {
return 'Please upload image, with size equal or less than 10MB';
}
}
});
Where /data is located at the root of the project, with mode 774. The user running meteor is the same who created the directory. However, when I run the app, I get
Error: [FilesCollection.users.avatars] Path "/data" is not writable! [401]
config.permissions and config.parentDirPermissions?/data ? Could you show output of ls -la?0774)/data have drwxrwxr-x 3 yanick yanick 4096 Sep 7 14:19 data/ for permissions.Have you tried 0777 (_as a test_)?
Even if it worked, this would be quite a huge security risk... but it doesn't work anyhow; I still get the same error. ... Does it actually try to set to /data from the project root, or /data from the root of the FS??
I just tried data (with no leading slash) and it seems to work. This is actually contrary to Meteor's specification that everything is absolute to the project root path. So, /data should not mean "from the root of the file system" !
leading / is server root, without slash is relative to running nodejs process
It's actually explained in FAQ:
Where files is stored by default?: by default if config.storagePath isn't passed into Constructor it's equals to assets/app/uploads and relative to running script:
On development stage: yourDevAppDir/.meteor/local/build/programs/server, note: all files will be removed as soon as your application will rebuild or you run meteor reset. To keep you storage persistent use absolute path outside of your project folder, we recommend to use /data directory
On production: yourProdAppDir/programs/server
Exactly :
To keep you storage persistent use absolute path outside of your project folder, we recommend to use /data directory
Which I supposed /data meant a directory named data at the root of the project! Which doesn't seem to be the case, since you mention /data is at the root of the server. Meteor's specification on paths is that /data would be at the root of the project (i.e. "relative to running nodejs process")
I understand that paths in this case, and paths when loading modules are two separate things, their behaviors are nonetheless contradictory, and the docs is not clear on the subject.
PR to docs is welcome
and the docs is not clear on the subject
Why? It's clearly says:
absolute path outside of your project folder
A path such as data is relative, not absolute. A path such as /data is absolute.
However, /data indicate "absolute from the server root" and data is "absolute from the project path". What is clear about that? The doc does say /data _is_ absolute to the project folder, but it should really data instead. Also, according to Meteor's specs when loading modules, /data is absolute to the project root folder, when in this case it is absolute to the server root folder. Quite confusing.
We are speaking of FS.
So in FS any path with leading / means root of the FS.
JS modules and etc. has not relation to FS
Hi @yanickrochon
May I assume this issue as solved?
It seems so, in the sense that the app starts. However I haven't got around to actually test it, yet.
@yanickrochon let me know if I can help you with anything else, related to this package.
Please, support this project by:
Hello,
I'm getting similar error, below. How can I change the data path?
=> Exited with code: 1
W20170706-12:54:47.682(-4)? (STDERR)
W20170706-12:54:47.683(-4)? (STDERR) /Users/isingh/Phamerator/phamerator/.meteor/local/build/programs/server/packages/ostrio_files.js:967
W20170706-12:54:47.683(-4)? (STDERR) throw new Meteor.Error(401, "[FilesCollection." + self.collectionName + "] Path \"" + self.storagePath({}) + "\" is not writable!", error);
W20170706-12:54:47.684(-4)? (STDERR) ^
W20170706-12:54:48.048(-4)? (STDERR) Error: [FilesCollection.Images] Path "/data/phamerator/uploads" is not writable! [401]
W20170706-12:54:48.049(-4)? (STDERR) at packages/ostrio_files/files.coffee:629:21
W20170706-12:54:48.049(-4)? (STDERR) at /Users/isingh/.meteor/packages/ostrio_files/.1.7.13.r9df1f++os+web.browser+web.cordova/npm/node_modules/fs-extra/lib/mkdirs/mkdirs.js:43:19
W20170706-12:54:48.049(-4)? (STDERR) at /Users/isingh/.meteor/packages/ostrio_files/.1.7.13.r9df1f++os+web.browser+web.cordova/npm/node_modules/fs-extra/lib/mkdirs/mkdirs.js:43:19
W20170706-12:54:48.050(-4)? (STDERR) at /Users/isingh/.meteor/packages/ostrio_files/.1.7.13.r9df1f++os+web.browser+web.cordova/npm/node_modules/fs-extra/lib/mkdirs/mkdirs.js:55:43
W20170706-12:54:48.050(-4)? (STDERR) at /Users/isingh/.meteor/packages/ostrio_files/.1.7.13.r9df1f++os+web.browser+web.cordova/npm/node_modules/graceful-fs/polyfills.js:284:29
W20170706-12:54:48.050(-4)? (STDERR) at FSReqWrap.oncomplete (fs.js:82:15)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
Hello @singhindresh ,
ostrio:files version you're on?storagePath optionchmod 777 /storage/path, note 777 is not the best in terms of security, but will do the trick for testing purposeI'm on Meteor 1.4.4.3 and looks like ostrio:files is trying to access the file in root context which doesn't have required files. How can I change the storagePath is somewhere else where can I create folder for storagePath?
Thank
Indresh
@singhindresh as I've mentioned before:
To change path use
storagePathoption
Most helpful comment
I just tried
data(with no leading slash) and it seems to work. This is actually contrary to Meteor's specification that everything is absolute to the project root path. So,/datashould not mean "from the root of the file system" !