Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to return ObjectsList from deletedObject request #1259

Open
werto165 opened this issue Jan 29, 2025 · 0 comments
Open

How to return ObjectsList from deletedObject request #1259

werto165 opened this issue Jan 29, 2025 · 0 comments

Comments

@werto165
Copy link

Hi All,

I want to validate that an object is deleted I have tried via the DELETE request but that returns 204 if its successful or fails, so this lead to me to try the POST delete request which is done via:
https://minioURL/bucket/?delete=

<Delete>
   <Object>
      <Key>/folder/file.pdf</Key>
   </Object>
</Delete>

The response I get is:

<?xml version="1.0" encoding="UTF-8"?>
<DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Deleted>
        <DeleteMarker>true</DeleteMarker>
        <DeleteMarkerVersionId>123e1faf-7bb0-4a92-a2f1-ae8dd304d816</DeleteMarkerVersionId>
        <Key>folder/file.pdf</Key>
    </Deleted>
</DeleteResult>

This means if the delete marker and the delete marker version id exist I can say that a file has been deleted, I know technically when you delete it multiple times it will return whatever the current versionId is. This is under the assumption that versioning is enabled on the bucket.
However from the C# client it uses a hardcoded "Quiet"

deleteObjectsRequest = new XElement("Delete", objects,
new XElement("Quiet", true));
requestMessageBuilder.AddXmlBody(Convert.ToString(deleteObjectsRequest, CultureInfo.InvariantCulture));

which only returns:

<?xml version="1.0" encoding="UTF-8"?><DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></DeleteResult>

That only helps a little bit because internally it calls this and only returns errors that are present.

private async Task<IList<DeleteError>> RemoveBucketObjectsAsync(RemoveObjectsArgs args,
CancellationToken cancellationToken)
{
var requestMessageBuilder = await this.CreateRequest(args).ConfigureAwait(false);
using var response =
await this.ExecuteTaskAsync(ResponseErrorHandlers, requestMessageBuilder,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
var removeObjectsResponse = new RemoveObjectsResponse(response.StatusCode, response.Content);
return removeObjectsResponse.DeletedObjectsResult.ErrorList;
}

Is there a way to either expose this via the constructor to the RemoveObjectsArgs so it would take in Quiet and based on that would return different values I know that's not the most extensible way of doing it. Any guidance on this would be appreciated.

It would also mean that the object list would need to be passed up the call stack,

public async Task<IList<DeleteError>> RemoveObjectsAsync(RemoveObjectsArgs args,
CancellationToken cancellationToken = default)
{
args?.Validate();
IList<DeleteError> errs = new List<DeleteError>();
errs = args.ObjectNamesVersions.Count > 0
? await RemoveObjectVersionsHelper(args, errs.ToList(), cancellationToken).ConfigureAwait(false)
: await RemoveObjectsHelper(args, errs, cancellationToken).ConfigureAwait(false);
return errs;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant