Meteor-files: Need help understanding S3 integration

Created on 17 Mar 2018  路  4Comments  路  Source: veliovgroup/Meteor-Files

Just have a short question regarding the S3 integration:

According to the docs, the FilesCollection should be declared in the imports/server dir, which totally makes sense to protect AWS credentials and such.

I'm quite new to Meteor, so it's not clear to me how I could insert files from the client with this approach? Isn't it impossible to import the FilesCollection to the client if it's declared in imports/server?

I managed to declare the FilesCollection in collections and then hook up the onAfterUpload (uploading the files to S3 and deleting the local copy) but there's no way to do the same with interceptDownload right?

Appreciate a little help!

question

All 4 comments

Hello @JanSchuermannPH ,

We're recommend to follow "exact code splitting" technique.
As example you can take a look on file structure at our demo app.

Shortly:

  • FilesCollection initiated twice with different options for Client and Server

That makes sense, I'll check it out and see if that makes things a bit clearer to me haha

So when doing this, I'm getting an error when starting the server "There is already a collection named 'images'".
Is this because the original collection is in a shared folder and the new one (with the S3 hooks) is in a server-only folder? Should the collections then be completely separated, so the one for the client in client-only folder, the one for server in (obviously) server-only folder?

EDIT
Okay, I followed the demo you linked exactly and although it doesn't make sense 100% yet, it all works as expected 馃憤

Hello @JanSchuermannPH ,

No, collections should have the same name at both Server and Client.
If you're getting this error, some of the code are isomorphic and executed on both Server and Client.
I believe simple console.log with name of the files will show you what files where imported.

Was this page helpful?
0 / 5 - 0 ratings