uploadcare / uploadcare-node

Node module for uploadcare.com
MIT License
37 stars 21 forks source link

Added option to wait until file is ready for download #19

Closed BenLorantfy closed 6 years ago

BenLorantfy commented 7 years ago

The /status endpoint returns success when the image is done uploading but that doesn't necessarily mean it's ready to be downloaded/accessed. The is_ready flag means it's ready to download. Added an option that if true tells the fromUrl function to wait until the image is ready before calling the callback function.

See the example response here: https://uploadcare.com/documentation/upload/#from-url

{
  "status": "success",
  "is_stored": true,
  "done": 145212,
  "file_id": "575ed4e8-f4e8-4c14-a58b-1527b6d9ee46",
  "total": 145212,
  "size": 145212,
  "uuid": "575ed4e8-f4e8-4c14-a58b-1527b6d9ee46",
  "is_image": true,
  "filename": "EU_4.jpg",
  "is_ready": true, <---- means it's ready to download
  "original_filename": "EU_4.jpg",
  "mime_type": "image/jpeg",
  "image_info": {
    "orientation": null,
    "format": "JPEG",
    "height": 640,
    "width": 960,
    "geo_location": null,
    "datetime_original": null
  }
}
BenLorantfy commented 6 years ago

@RexMorgan what do you think of this PR?

RexMorgan commented 6 years ago

Hi Ben, I like this change and I'll try to test this and get it merged and published to npm soon.

I'm very sorry for the long delay, I know lack of response can be frustrating with open source projects. I saw this when you originally sent it and I forgot to set aside time to look into it more closely. Thanks for bringing it back to my attention.

RexMorgan commented 6 years ago

@BenLorantfy This has been merged and published to npm, uploadcare version 0.4.4.

Thanks!