cloudinary/cloudinary_android

Delete image

AjithNoah opened this issue · 4 comments

How can i delete particular and mutiple image from cloudinary?? i've searched a lot but didnt found appropriate solution..

Deleting your account resources can be done in the following ways:

  1. Via the media library UI, either bulk deleting: https://cloudinary.com/console/settings/bulk_delete/new or selecting few images in the media library and deleting them.
  2. Using the Admin API - Either http://support.cloudinary.com/entries/26856651-How-can-I-bulk-delete-all-my-account-s-resources- or by http://cloudinary.com/documentation/admin_api#delete_resources
  3. Deleting a single file can be done via the API with the destroy method: https://cloudinary.com/documentation/image_upload_api_reference#destroy_method

im uploading image like this using MediaManager.. where to use destroy method???

Thanks for reply..

MediaManager.get().upload(cloudpath)
.option("public_id", imageFileName)
.option("resource_type", resourcetype)
.callback(new UploadCallback() {
@OverRide
public void onStart(String requestId) {

                }

                @Override
                public void onProgress(String requestId, long bytes, long totalBytes) {
                   /* Double progress = (double) bytes/totalBytes;
                    String numberD = String.valueOf(progress);
                    numberD = numberD.substring ( numberD.indexOf ( "." ) );
                    Toast.makeText(getActivity(), numberD, Toast.LENGTH_SHORT).show();*/
                }

                @Override
                public void onSuccess(String requestId, Map resultData) {
                    hideProgress();
                    if (isImage) {
                        filterThumModel.clear();
                        addFilter(resultData.get("public_id").toString(), resourcetype);
                    } else {
                        MediaManager.get().url().transformation(new Transformation().quality(50)).resourceType("video").generate(resultData.get("public_id").toString());
                    }
                  //  Toast.makeText(getActivity(), R.string.fileuploadedtocloud, Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onError(String requestId, ErrorInfo error) {
                    hideProgress();
                    Toast.makeText(getActivity(), error.getCode(), Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onReschedule(String requestId, ErrorInfo error) {
                }
            }).dispatch();
igy commented

The destroy() method requires the API call to be signed. This means that it's not suitable for use in client code because you'd need to include the account secret in the client code, which would compromise your account security.

For most cases, you should use one of the methods Aditi recommended.
It is also possible to delete from the client side for a short time (10 minutes) after a client-side upload - for that, you should specify the return_delete_token parameter in the upload call, and the upload response will contain a token which can be used to delete the new image for 10 minutes. There's a specific section of the documentation explaining this use case: https://cloudinary.com/documentation/upload_images#deleting_client_side_uploaded_images

Please see if that works for you; if not, the methods which Aditi mentioned should be used from your server or browser.

igy commented

I'm going to close this as it seems the answers above should cover this; if you have any further issues please open a new issue or contact our support team via https://support.cloudinary.com