Skip to content
This repository has been archived by the owner on Aug 17, 2019. It is now read-only.

Uploading an image results in an empty array and the application hanging #101

Open
kodie opened this issue Jan 8, 2017 · 12 comments
Open

Comments

@kodie
Copy link

kodie commented Jan 8, 2017

Here is my code:

var Flickr = require("flickrapi"),
    flickrOptions = {
      "user_id": "(Hidden)",
      "api_key": "(Hidden)",
      "api_secret": "(Hidden)",
      "access_token": "(Hidden)",
      "access_token_secret": "(Hidden)",
      "permissions": "write"
    };

Flickr.authenticate(flickrOptions, function(error, flickr) {
  if (!error) {
    var uploadOptions = {
      photos: [{
        title: "test",
        photo: __dirname + "/image.png"
      }]
    };

    Flickr.upload(uploadOptions, flickrOptions, function(err, res) {
      if (!err) {
        console.log(res);
      } else { throw err; }
    });
  } else { throw error; }
});

After a couple of seconds I get [] printed out in the console and the application never finishes running so I have to hit CTRL+C to force end the app.

@Pomax
Copy link
Owner

Pomax commented Jan 8, 2017

Technically neither of those things are signs that your upload went wrong, although they suggest something else might be wrong. If there were no errors, presumably the upload worked and your Flickr page will now show that image in your stream. Is it not there?

The code that does the actual post and leads to a result callback is https://github.com/Pomax/node-flickrapi/blob/master/src/utils.js#L409-L419, so seeing an empty array suggests you do hit https://github.com/Pomax/node-flickrapi/blob/master/src/utils.js#L416 but the response is not what the code expects. In this case I'd recommend doing a quick code modification: slot

} else if (body.indexOf('rsp stat="ok"')>-1) {
  console.log(body);
  data = parseInt(body.split.....
}

and see what that's in that response body.

@kodie
Copy link
Author

kodie commented Jan 8, 2017

The image was never uploaded. I was able to get the image to upload using the same api credentials with https://github.com/flickr/flickr-sdk

I'll give your code change a try and see what happens.

@LahiruBandara
Copy link

I have the exact same issue. Moving out to https://github.com/flickr/flickr-sdk

@Pomax
Copy link
Owner

Pomax commented Apr 28, 2017

@LahiruBandara cool - before you do, or while, can you supply the information that @kodie ended up not following up with so that perhaps this bug can still be fixed for others that run into it?

@madkoding
Copy link
Contributor

same here... response is empty on image upload = [ ]
also, the "uploaded image" never appears in flickr

@madkoding
Copy link
Contributor

madkoding commented Sep 29, 2017

Guys, i add a pull request replacing the current response parsing using the xml2json module... also will give the correct error response (that no show in the actual code, that's why response is empty) @Pomax

@Pomax
Copy link
Owner

Pomax commented Sep 29, 2017

nice, if you can update that to a single PR I'll be happy to review and merge.

@madkoding
Copy link
Contributor

There is @Pomax o/

@Pomax
Copy link
Owner

Pomax commented Oct 1, 2017

@madkoding why did you close both PRs?

@madkoding
Copy link
Contributor

closed by mistake :P

@Pomax
Copy link
Owner

Pomax commented Oct 2, 2017

hehe, gotcha =)

@truonghoangphuc
Copy link

How is the status now? I just got this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants