Cloudinary

官方网址:https://cloudinary.com

php sdk: https://github.com/cloudinary/cloudinary_php_v2

nodejs sdk : https://www.npmjs.com/package/cloudinary

api地址:https://cloudinary.com/documentation/cloudinary_references

node 实例

const cloudinary = require('cloudinary');


cloudinary.config({
    "cloud_name": "",
    "api_key": "",
    "api_secret": ""
});


// 一些reporter信息
cloudinary.v2.api.usage(function(error, result) {

    //console.log(result);

});

// search
cloudinary.v2.search
//.expression('tags:"productId:8718475849711"')
// .expression('public_id="live/*"')
//.expression('public_id="live/8718475964872/11*"')
    .expression('created_at >= 2020-03-19 AND created_at<=2020-03-20')
    //.expression('created_at > 2020-02-01')
    .with_field('tags')
    .sort_by('public_id','desc')
    .max_results(0)
    .execute().then(result=>console.log(result['total_count']));

php代实例

upload

注意一个概念:Transformations

这个是在transformations中设置一些不同的规格.

然后upload的时候,通过eager参数进行设置是否需要转换成什么规格的.

注意:Transformations的resize 的图片不计算在 image 数据量上.比如现在39,上传了一张图片,并且resize 了4种规格.,但是图片总数量只会是增加1.

注意:当你replace一张图片,public id 是唯一标注图片的.替换图片,created_at 不会变,只会变update_at(在公司里,是先purge,所以每次会是一张新的created,而非替换)

Last updated

Was this helpful?