Skip to content

Conversation

@poying
Copy link

@poying poying commented Jan 7, 2014

api, napi

@prabirshrestha
Copy link
Contributor

Any particular reason for returning the request object?

Note: This would also mean less compatibility with the official Facebook JS SDK. Something we try to avoid.

@poying
Copy link
Author

poying commented Jan 8, 2014

I want to upload photo to facebook but the following codes seems not work.

FB.api('me/photos', 'post', {form: ...}, function () {});

If I can get request object then I can done the job like this.

var form = FB.api('me/photos', 'post', {form: ...}, function () {}).form();
form.append(...);

@prabirshrestha
Copy link
Contributor

@poying form attachments api is something I have been internally playing around. Here is what I want it to sort of look like. Let me know how you think of it.

Let me know what you think of this.

FB.api('/me/photos', post, {
    message: 'photo upload',
    _attachements: { // especial key understood by fb sdk
        photo: { // key of the multipart form data. useful when referencing in batch requests.
            filename: 'photo.jpg',   
            contentType: 'image/jpeg',
            data: ....
        }
    }
}, function(res) {

});

data can be multiple stuffs.

  • string: file path
  • Stream: node streams
  • function: with callback as parameter. callback(err) or callback(null, string), or callback(null, Stream).

@poying
Copy link
Author

poying commented Jan 9, 2014

That is great !

Maybe contentType can be auto-detected. (request will do this for us)

@prabirshrestha
Copy link
Contributor

Thats a good catch for contentType getting detected automatically.

In the mean time feel free to submit a PR if you would like too.

@dantman
Copy link

dantman commented Jan 25, 2016

File uploads are now supported in 1.1.0-alpha1 without needing the special _attachments key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants