meteor-file-collection icon indicating copy to clipboard operation
meteor-file-collection copied to clipboard

Compatibility with Apollo-server.

Open cbilotta opened this issue 8 years ago • 5 comments

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!

cbilotta avatar May 25 '17 14:05 cbilotta

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"

vsivsi avatar May 25 '17 18:05 vsivsi

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 :)

cbilotta avatar May 25 '17 21:05 cbilotta

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.

vsivsi avatar May 25 '17 21:05 vsivsi

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!

cbilotta avatar May 25 '17 21:05 cbilotta

Good luck!

vsivsi avatar May 25 '17 22:05 vsivsi