imeji-community / imeji

imeji source code can now be found on https://github.com/MPDL/imeji.
https://github.com/MPDL/imeji
13 stars 15 forks source link

API: when creating an item via `fetchUrl` the `content-type` sent by the server is not respected. #1115

Open xrotwang opened 8 years ago

xrotwang commented 8 years ago

I try to create an item using the following JSON message:

{
    "fetchUrl": "https://raw.githubusercontent.com/clld/clld.github.io/master/images/sino-tibetan.jpg", 
    "collectionId": "1Qi5Q3J6e0Vjeyc_"
}

which results in the following error response:

DEBUG:requests.packages.urllib3.connectionpool:"POST /rest/items HTTP/1.1" 422 173
ERROR:pyimeji.api:got HTTP 422, expected HTTP 201
ERROR:pyimeji.api:{
  "error" : {
    "code" : "1422",
    "title" : "Unprocessable Entity",
    "message" : "1422-message",
    "exceptionReport" : "upload_format_not_allowed:  (null)"
  }
}

I think this is a bug, because the server sends the correct content-type header to be used for the item:

(pyimeji)robert@astroman:~/venvs/pyimeji$ curl -I https://raw.githubusercontent.com/clld/clld.github.io/master/images/sino-tibetan.jpg
HTTP/1.1 200 OK
Content-Type: image/jpeg
natasab commented 8 years ago

Could not reproduce it..

POST https://dev-faces.mpdl.mpg.de/rest/items BODY:

{"collectionId":"584Cq4n5sQZUVkFT", "fetchUrl":"https://raw.githubusercontent.com/clld/clld.github.io/master/images/sino-tibetan.jpg"}

Response

     {
       "id": "uF60xatDliVbguJJ",
     "createdBy": {
     "fullname": "imeji, admin",
     "userId": "WuExL7x5lGcyZpU"
       },
      "modifiedBy": {
     "fullname": "imeji, admin",
     "userId": "WuExL7x5lGcyZpU"
     },
    "createdDate": "2015-07-20T09:57:34 +0200",
    "modifiedDate": "2015-07-20T09:57:34 +0200",
    "versionDate": "",
    "status": "PENDING",
    "version": 0,
    "visibility": "PRIVATE",
    "collectionId": "584Cq4n5sQZUVkFT",
    "filename": "sino-tibetan.jpg",
    "mimetype": "image/jpeg",
    "checksumMd5": "8f077375cf3cdea65529733337d6ca67",
    "webResolutionUrlUrl": "https://dev-faces.mpdl.mpg.de/file/584Cq4n5sQZUVkFT/7d/e2/53/e0-78bb-47f1-a55a-45f9dafda544/0/web/892f7d5476056c0764549db6e185413e.jpg",
    "thumbnailUrl": "https://dev-faces.mpdl.mpg.de/file/584Cq4n5sQZUVkFT/7d/e2/53/e0-78bb-47f1-a55a-45f9dafda544/0/thumbnail/892f7d5476056c0764549db6e185413e.jpg",
    "fileUrl": "https://dev-faces.mpdl.mpg.de/file/584Cq4n5sQZUVkFT/7d/e2/53/e0-78bb-47f1-a55a-45f9dafda544/0/original/892f7d5476056c0764549db6e185413e.jpg",
    "metadata": [],
    "fileSize": 345878
      }