关注代码:
string[] files
= System.IO.Directory.GetFiles(@"C:\Users\Matheus Miranda\Pictures", "*.jpg");
foreach (var file in files)
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(file),
PublicId = "my_folder/images",
EagerAsync = true
};
var uploadResult = cloudinary.Upload(uploadParams);
}
它不起作用,它总是记录以前的文件。
我正在尝试将多个图像保存到cloudinary,但没有成功。
仅保存一张图像。我使用的是Cloudinary。
任何解决方案吗?
答案 0 :(得分:1)
当我对其进行测试时,它可以按预期工作;但是,我会调整几件事。第一件事是您不需要参数eager_async
,因为没有eager
转换未应用于资产。急切的转换使您可以在资产上载后异步创建原始版本的修改版本。其次,如果您希望查看上传响应,则可以使用属性JsonObj并将其显示在控制台中。我在这里修改了您的示例:
string[] files
= System.IO.Directory.GetFiles(@"C:\Users\Matheus Miranda\Pictures", "*.jpg");
foreach (var file in files)
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(file),
UseFilename = true
};
var uploadResult = cloudinary.Upload(uploadParams);
Console.WriteLine(uploadResult.JsonObj);
}
答案 1 :(得分:0)
我找到了解决方案!
string[] files =
System.IO.Directory.GetFiles(@"C:\Users\Matheus Miranda\Pictures\teste", "*.jpg");
for (int i = 0; i < files.Length; i++)
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(files[i]),
PublicId = $"my_folder/images/{System.IO.Path.GetFileName(files[i])}"
};
var uploadResult = cloudinary.Upload(uploadParams);
}