kinto-attachment
kinto-attachment copied to clipboard
Support Kinto.js
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.
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...
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:
- Store the file metadata as a record so I can retrieve just the meta about files without the files themselves.
- 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.
- 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.
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...
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.
@chrismbeckett Great, do not hesitate to ask your question on the IRC channel if you need any help or assistance.
Any news on this? I would need offline file sync/upload, too!
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?)