[Solved] Meteor-files not storing image with storagePath

#1

I’m using https://github.com/VeliovGroup/Meteor-Files for image uploads.

My problem is that when I set storagePath it does not store images anywhere, even though the upload is successful (it says). If I remove storagePath then it stores them in the .meteor folder.

export const Images = new FilesCollection({
    collectionName: 'Images',
    allowClientCode: false,
    storagePath: '/public/uploads/avatars',
    onBeforeUpload(file) {
        if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
            return true;
        }
        return 'Please upload image, with size equal or less than 10MB';
    }
});

Any idea why it’s acting up like this? I am running on Windows so there isn’t any permission error.

#2

Do you have these directories at the root of your file system (root of hard drive)?

2 Likes
#3

@dr.dimitru OK, that makes a lot of sense (not really). Thanks for the input.
Do you have any clue on how I can save the images to the relative /public/ folder in my project directory (automatically)?

#4
  • Relative - public/uploads/avatars (note: it’s relative to running script)
  • Absolute - /public/uploads/avatars

I recommend to use meteor-root package to build a path relative to Meteor project in the way you want.

From the FAQ:

  1. Where are files 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 rebuilds or you run meteor reset. To keep your storage persistent during development use an absolute path outside of your project folder, e.g. /data directory.
    • On production: yourProdAppDir/programs/server. Note: If using MeteorUp (MUP), Docker volumes must to be added to mup.json, see MUP usage
4 Likes
#5

I decided to just store them in an absolute path called /local/my-project-name. Thanks for your help!

1 Like