如何在将图像上传到cloudinary服务器时更改图像的名称?

时间:2018-02-20 16:22:09

标签: javascript cloudinary

我正在尝试将base64中的图像名称更改为稍后定义的名称。我该怎么做?我想自定义cloudinary服务器中的名称

  var uploadOptions = {
    params : {
      //'upload_preset': "YOUR_IMAGE_UPLOAD_PRESET",
      'upload_preset': "xxx",
    }

//imageURI is base64 image
//.upload("YOUR_IMAGE_UPLOAD_LINK", imageURI, uploadOptions)
  .upload("https://api.cloudinary.com/v1_1/xxxx/image/upload", imageURI, uploadOptions)

    .then(function(result) {

1 个答案:

答案 0 :(得分:1)

使用public_id参数命名图像,例如:

var uploadOptions = {
    params : {
      //'upload_preset': "YOUR_IMAGE_UPLOAD_PRESET",
      'upload_preset': "xxx",
      'public_id': "imageName"
    }

它还可以包含文件夹。例如:

'public_id': "myfolder/imagename"

或者

'public_id': "imagename"
'folder': "myfolder"

您可以详细了解here