How to construct image url from Axomic OpenAsset R

2019-08-08 20:55发布

问题:

I'd like to get the URL for an image that is stored in our OpenAsset server. I can curl a request to get the file's information:

curl -u myUsername:myPassword -X GET http://our.IP.address//REST/1/Files/11 | json_pp

and I can reverse engineer the url that their front end uses to show me an image:

our.IP.address/Serve/DirectImage/imageId.7235-defaultImageSizeId.1

But trying to do some kind of string format to make the url feels hacky. E.g.:

"our.IP.address/Serve/DirectImage/imageId.{}-defaultImageSizeId.1".format(theImageID)

Is there a way get a url directly from the rest request? Is this the correct way to do it?

The OpenAsset REST API is in beta still, so its documentation is surprisingly good given that fact.

回答1:

starting with : curl -u username:password -X GET http://my.IP.add.ress//REST/1/Files/

{
    "copyright_holder_id" : "0",
    "download_count" : "1",
    "original_filename" : "C990705_Colleges_011.tif",
    "photographer_id" : "0",
    "contains_video" : "0",
    "md5_now" : "",
    "category_id" : "1",
    "caption" : "",
    "md5_at_upload" : "90d661ec1...06b71",
    "id" : "11",
    "project_id" : "854",
    "click_count" : "2",
    "rotation_since_upload" : "0",
    "alternate_store_id" : "0",
    "duration" : "0",
    "description" : "",
    "created" : "0",
    "filename" : "C990705_N1.tif",
    "uploaded" : "20101202062201",
    "contains_audio" : "0",
    "user_id" : "12",
    "access_level" : "2",
    "rank" : "5"
}

Which is the information about the original file as it was uploaded. To get to a downloadable file you need to go to the sizes route.

curl -u username:password -X GET http://my.IP.add.ress//REST/1/Files/11/Sizes | json_pp

Which gives a list of the possible sizes and formats.

[
    {
        "unc_root" : "//SYD-OA001/openasset/",
        "width" : "1383",
        "watermarked" : "0",
        "relative_path" : "Projects/C990705/C990705_N1_tif/C990705_N1_medium.jpg",
        "colourspace" : "RGB",
        "y_resolution" : "150",
        "height" : "666",
        "http_root" : "/Images/",
        "filesize" : "106363",
        "x_resolution" : "150",
        "recreate" : "0",
        "id" : "8",
        "quality" : "0",
        "file_format" : "jpg"
    },
    {
        "width" : "1383",
        "unc_root" : "//SYD-OA001/openasset/",
        "watermarked" : null,
        "relative_path" : "Projects/C990705/C990705_N1.tif",
        "colourspace" : "CMYK",
        "y_resolution" : "300",
        "height" : "666",
        "x_resolution" : "300",
        "filesize" : "3697734",
        "http_root" : "/Images/",
        "id" : "1",
        "quality" : "0",
        "file_format" : "tif"
    }
]

To get to the file you want you'll need to search this list for the right size and format, and then concatinate the unc_root and the relative_path.



标签: rest