Destroy files returns always "not found"
I am trying to delete files. The public_id is exactly the same as I uploaded the file. I use asp.net with c#. The result is always "not found".
public static ImageUploadResult CloudinaryFileUpload(Account account, string file, string folder, string public_id)
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(file),
Folder = folder,
Overwrite = true,
PublicId = public_id
};
Cloudinary cloudinary = new Cloudinary(account);
ImageUploadResult result = cloudinary.Upload(uploadParams);
return result;
}
public static DeletionResult CloudinaryFileDelete(Account account, string public_id)
{
Cloudinary cloudinary = new Cloudinary(account);
var deletionParams = new DeletionParams(public_id)
{
Invalidate = true,
Type = "upload",
ResourceType = ResourceType.Image
};
DeletionResult result = cloudinary.Destroy(deletionParams);
return result;
}
-
Hi,
Looking at your logs and your account, I see that all your resources are located inside a folder. However, your destroy requests lack this folder (it should be represented either in the public_id or by using the `folder` parameter).
Additionally, your public_ids contain white spaces which are not recommended. In these cases, Cloudinary replaces the black space with an underscore.
If you'd like more specific help, please open a support ticket so we would be able to share the names of the folder, public_ids, etc.0 -
Integrating the folder in public_id helps. Thanks very much. Suggestion: Offer parameter Folder at GetResource, Destroy, ... at asp.net.
0 -
Hi,
Thanks for the update and feedback.
In general, the public_id always include the folders; that's how it's returned by our API and how it should be stored in your database or other storage layer.
The upload() API method is an exception; in that API the folder parameter allows you to choose a folder in which the uploaded file should be placed. Using that parameter means that instead of specifying the full public_id directly, you can choose to name the file based on the file's original filename, or by choosing a random alphanumeric value, but have it placed in a specific folder afterward (with the folder becoming part of the final public_id)
Regards,
Stephen
0
Post is closed for comments.
Comments
3 comments