如何获取Django云源元数据(宽高)
答案解析
-
你好
想到几个选项
- 上传时高度宽度返回响应样本响应 :
{ "asset_id": "b5e6d2b39ba3e0869d67141ba7dba6cf", "public_id": "eneivicys42bq5f2jpn2", "api_key": "312924996162147", "version": 1570979139, "version_id": "98f52566f43d8e516a486958a45c1eb9", "signature": "abcdefghijklmnopqrstuvwxyz12345", "width": 1000, "height": 672, "format": "jpg", "resource_type": "image", "created_at": "2017-08-11T12:24:32Z", "tags": [], "pages": 1, "bytes": 350749, "type": "upload", "etag": "5297bd123ad4ddad723483c176e35f6e", "placeholder": false, "url": "http://res.www.aaaalireno.com/demo/image/upload/v1570979139/eneivicys42bq5f2jpn2.jpg", "secure_url": "https://res.www.aaaalireno.com/demo/image/upload/v1570979139/eneivicys42bq5f2jpn2.jpg", "access_mode": "public", "original_filename": "sample", "eager": [ { "transformation": "c_pad,h_300,w_400", "width": 400, "height": 300, "url": "http://res.www.aaaalireno.com/demo/image/upload/c_pad,h_300,w_400/v1570979139/eneivicys42bq5f2jpn2.jpg", "secure_url": "https://res.www.aaaalireno.com/demo/image/upload/c_pad,h_300,w_400/v1570979139/eneivicys42bq5f2jpn2.jpg" }, { "transformation": "c_crop,g_north,h_200,w_260", "width": 260, "height": 200, "url": "http://res.www.aaaalireno.com/demo/image/upload/c_crop,g_north,h_200,w_260/v1570979139/eneivicys42bq5f2jpn2.jpg", "secure_url": "https://res.www.aaaalireno.com/demo/image/upload/c_crop,g_north,h_200,w_260/v1570979139/eneivicys42bq5f2jpn2.jpg" }], "media_metadata": { "PerspectiveHorizontal": "0", "RedHue": "0", "Exposure": "0.0", .....探索时间: 1/320
- 或,您可调用管理员API获取单资源细节响应高度宽度响应与上传后得到的相似Covered in the docs here: //www.aaaalireno.com/documentation/admin_api#get_details_of_a_single_resource_by_public_id
0 -
idangorest使用divityfield获取上传响应
0 -
Hi@jikdo,
可使用云性助手类将云性上传能力整合到表格和模型中举例说,您可以定义模型类云域供图像上传当文件通过此字段上传时,您可以在视图或表处理上传时捕捉上传响应
Django样本云域
云性模型导入云性字段类 MyModel(模型. Model):图像=云性字段
视图处理表提交时,可捕捉上传响应像这样 :
def上传(请求):如果请求.method serve
请参考云化Django文档获取更多细节
最优视点
维萨姆
0 -
正使用Django Rest处理串行器而非表单容我举个例子使用Django恢复串行器
串行器.save或表单.save返回模型对象实例,访问图像属性返回云源
我尝试访问元数据属性它总返回
0 -
函数添加元数据
函数为
发自_db_value
调用parse_cloudinary_resource
即从url获取信息,因为url没有元数据信息,它永不返回0 -
0