如何从Axomic OpenAsset REST API构造图像URL

时间:2014-03-27 02:06:55

标签: rest

我想获取存储在OpenAsset服务器中的图片的网址。我可以卷曲请求获取文件的信息:

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

我可以对他们的前端用来向我显示图像的网址进行反向工程:

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

但是尝试使用某种字符串格式来使网址感觉很糟糕。 E.g:

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

有没有办法直接从其余请求获取网址?这是正确的方法吗?

OpenAsset REST API仍处于测试阶段,因此,鉴于此事实,其文档非常出色。

1 个答案:

答案 0 :(得分:1)

从: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"
}

上传时原始文件的信息。要获取可下载文件,您需要转到sizes路径。

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

其中列出了可能的尺寸和格式。

[
    {
        "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"
    }
]

要转到您想要的文件,您需要在此列表中搜索正确的大小和格式,然后合并unc_rootrelative_path