vsivsi / meteor-file-collection

Extends Meteor Collections to handle file data using MongoDB gridFS.
http://atmospherejs.com/vsivsi/file-collection
Other
159 stars 37 forks source link

Compatibility with Apollo-server. #161

Open cbilotta opened 7 years ago

cbilotta commented 7 years ago

Hello,

I have a Graphql server (ApolloServer) separated from my main app. I handle auth using this package : https://github.com/orionsoft/meteor-apollo-accounts

So my quick questions are :

How can I upload via myCollection.resumable.upload() to another server (the Apollo server) ? Is it possible to get auth working with the package I mentioned ?

Thanks!

vsivsi commented 7 years ago

Hi, I don't know anything about ApolloServer. Currently file-collection only supports uploading to the Meteor server hosting the file-collection instance. The backing mongoDB can be anywhere.

Built-in authorization is only currently handled using Meteor account tokens, but file-collection is very flexible about handling metadata and determining which Requests/URIs map successfully to a file. So you could almost certainly write code to use another authentication scheme such as whatever ApolloServer does. But file-collection is agnostic about that and won't do it "out-of-the-box"

cbilotta commented 7 years ago

Ok I get it, So I just have to figure out how to send the resumable stuff to my other server ? Do I understand well what does myCollection.resumable.upload does :

1) Create a file on the server and get the ID or whatever back 2) Upload the file chunk by chunk using resumable APIs

Is that it ?

I'm sorry if I'm asking stupid questions but I have trouble navigation the source code due to the fact that I know nothing about coffee script.

If I'm successful I'll happily try to glue together a starter kit :)

vsivsi commented 7 years ago

So the main thing to know is that file-collection stores the file inside MongoDB using gridFS. That is the only place the files exist. The resumable.js upload chunks map 1:1 with gridFS chunks.

If you need files on the server filesystem (not in the database) then file-collection probably isn't for you. Although you could rig together something to automatically export files back out of the DB, that is probably overly complicated.

Unfortunately, I'm just about drop off of the internet for nearly a month, so I'm afraid I can't help you more now.

cbilotta commented 7 years ago

I knew about that 😃

I want to keep all the GridFS and resumable goodness that's why I'm trying to find a workaround!

I'll try to figure out how to upload to another server and mess around with the auth methods a bit.

Have a nice vacation & thanks for this great library!

vsivsi commented 7 years ago

Good luck!