当使用来自nextjs的cloudinary SDK上传图像并定义我想要存储它的文件夹时,它只是忽略它并将其上传到根目录。
这是我的实现。
import cloudinary from "cloudinary";
cloudinary.v2.config({
cloud_name: process.env.CLOUDINARY_NAME,
api_key: process.env.CLOUDINARY_KEY,
api_secret: process.env.CLOUDINARY_SECRET
})
export default cloudinary
const uploadedImageResponse = await cloudinary.uploader.upload(image.buffer, {
public_id: `skills/${v4()}`,
folder: "skills",
resource_type: "auto",
})
这是我的回应,文件夹被简单地忽略。
uploadedImageResponse >>>> {
asset_id: 'ee3e6c19da42a7c4634e6afe68c6ff7c',
public_id: 'cxnelcz7nfo6ufb5mjws',
version: 1675733703,
version_id: 'aec4829c30d5774b738ebbf6f3af2102',
signature: '4f81357787c8be97fa8e1c120cd9cc4293c33d6f',
width: 30,
height: 30,
format: 'png',
resource_type: 'image',
created_at: '2023-02-07T01:35:03Z',
tags: [],
bytes: 874,
type: 'upload',
etag: 'e1e912fea5a5ac5ce894d4e47e2ee374',
placeholder: false,
url: 'http://res.cloudinary.com/edsen/image/upload/v1675733703/cxnelcz7nfo6ufb5mjws.png',
secure_url: 'https://res.cloudinary.com/edsen/image/upload/v1675733703/cxnelcz7nfo6ufb5mjws.png',
folder: '',
}
我已启用"自动创建文件夹"选项。
1条答案
按热度按时间djmepvbi1#
请使用cloudinary.v2
即
从“cloudinary.v2”导入cloudinary;
希望这能有所帮助,如果您有任何进一步的问题,请让我知道。
最好的问候,莫