Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return request object #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

return request object #50

wants to merge 2 commits into from

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