我想获得的URL,存储在我们的图像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
但是,试图做一些字符串格式,使网址感觉哈克。 例如:
"our.IP.address/Serve/DirectImage/imageId.{}-defaultImageSizeId.1".format(theImageID)
有没有办法直接从其他请求得到一个url? 这是做了正确的方法是什么?
该OpenAsset REST API是测试版了,于是它的文档是出奇的好鉴于这一事实。
开始: 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"
}
]
为了得到你想要你需要搜索该列表中正确的大小和格式,然后concatinate的文件unc_root
和relative_path
。