kinto-attachment icon indicating copy to clipboard operation
kinto-attachment copied to clipboard

Support Kinto.js

Open ghost opened this issue 9 years ago • 7 comments

Any way to make this work with Kinto.JS Sync? It would be nice if I could attach the file offline in Kinto.JS, then have it extracted to S3 on the server during synch.

ghost avatar Feb 21 '16 21:02 ghost

Yep, indeed!

Would you be willing to work on it?

That would mean adding a notion of hooks in kinto.js so that file uploads is performed during synchronization of records with a attachment attribute. Same could be applied to downloads when records are fetched from server...

leplatrem avatar Feb 22 '16 16:02 leplatrem

I would help, I just don't have the skills in Python to handle this. I work mostly in NodeJS these days, and have never programmed in Python. Python as a language is not difficult, but its all the other stuff you have to learn to go with it: pyramid, cliquet, etc. is just more than I can take on right now.

My applications don't require huge amounts of files (or large files). After mulling this over, my short term solution is going to be to:

  1. Store the file metadata as a record so I can retrieve just the meta about files without the files themselves.
  2. Base64 encode the file and raw file information (ext, size, etc) as a separate record and reference link it to the meta record. Yes, this means storing the file in Postgres, but I can live with this for a while. This should work with KintoJS and sync, and solve the basic problem of handling files if the user if offline. I can live with capping the file size of a single attachment to something reasonable for a REST API post.
  3. Write a Kinto plugin that adds a custom attachment endpoint that allows me to get a Base64 embedded record attachment as an HTTP file stream so it can be shared as a link, or rendered in href tags if the user is online.

If I can circle back on this once I get my MVP launched (and my Python skills improve), I would love to contribute in the future.

ghost avatar Feb 22 '16 23:02 ghost

As far as I understand the part you are talking about is client side and not server side.

A Kinto.js hook is a little Javascript function:

That would mean adding a notion of hooks in kinto.js so that file uploads is performed during synchronization of records with an attachment attribute. Same could be applied to downloads when records are fetched from the server...

Natim avatar Feb 23 '16 08:02 Natim

Oh, I am sorry, I misunderstood. I was assuming that the hooks you were describing would be server-side. A plugin/mixin model coupled with hooks for KintoJS would allow the client-side sync to be extended to support any server-side plugin that provides extensions to the REST API.

Let me dig into the code for KintoJS over the next couple of days and see what I can do.

ghost avatar Feb 23 '16 08:02 ghost

@chrismbeckett Great, do not hesitate to ask your question on the IRC channel if you need any help or assistance.

Natim avatar Feb 23 '16 09:02 Natim

Any news on this? I would need offline file sync/upload, too!

nasenfloete avatar Jul 26 '18 13:07 nasenfloete

I don't think there has been any change in this issue's status. Feel free to take a crack at it if you like. (Maybe this issue should be in the kinto.js repository?)

glasserc avatar Jul 30 '18 23:07 glasserc