Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Fix #104: Add support for the attachment API. #115

Merged
merged 20 commits into from
Jul 18, 2016
Merged

Conversation

n1k0
Copy link
Contributor

@n1k0 n1k0 commented Jul 14, 2016

WiP, refs #104, cc @leplatrem.

I'm stuck here with this kinto server error Kinto/kinto-attachment#100

It's certainly a problem with the patch implementation as attaching a file using httpie and the kinto admin both work just fine. It may be related to jsdom's FormData implementation.

I'd be happy to get some help here.

@leplatrem
Copy link
Contributor

Yes, it is combination of isomorphic-fetch and jsdom FormData I guess.
The header Content-Type is not sent with multipart automatically, and from the server side the body appears empty.

In the examples given on node-fetch they use the form-data package

// post with form-data (detect multipart)

var FormData = require('form-data');
var form = new FormData();
form.append('a', 1);
fetch('http://httpbin.org/post', { method: 'POST', body: form })
    .then(function(res) {
        return res.json();
    }).then(function(json) {
        console.log(json);
    });

I pushed a very dirty commit on the branch with some code that works... let's say it's step 1, but it introduces some ugly dependencies to form-data package and node Buffer (whose browserify counterpart is huge), just to run the tests :)

@leplatrem leplatrem force-pushed the 104-attachment-api-support branch from ab51388 to 2a02003 Compare July 14, 2016 12:34
@leplatrem
Copy link
Contributor

Made something slightly better...

* @param {Object} [options.permissions] The permissions option.
* @return {Promise<Object, Error>}
*/
addAttachment(dataURI, record={}, options={}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add @capable decorator

@n1k0 n1k0 force-pushed the 104-attachment-api-support branch from 3dcce8f to 845a5e4 Compare July 18, 2016 16:47
@n1k0 n1k0 merged commit 48eb04e into master Jul 18, 2016
@n1k0 n1k0 deleted the 104-attachment-api-support branch July 18, 2016 17:10
n1k0 added a commit that referenced this pull request Jul 18, 2016
Fix #104: Add support for the attachment API. (#115)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants