123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using COSXML.Model.Tag;
- using COSXML.Common;
- using COSXML.Network;
- using COSXML.CosException;
- namespace COSXML.Model.Object
- {
-
-
-
-
- public sealed class DeleteMultiObjectRequest : ObjectRequest
- {
-
-
-
-
- private Delete delete;
- public DeleteMultiObjectRequest(string bucket)
- : base(bucket, "/")
- {
- this.method = CosRequestMethod.POST;
- this.queryParameters.Add("delete", null);
- delete = new Delete();
- delete.deleteObjects = new List<Delete.DeleteObject>();
- }
-
-
-
-
-
-
- public void SetDeleteQuiet(bool quiet)
- {
- delete.quiet = quiet;
- }
-
-
-
-
- public void SetDeleteKey(string key)
- {
- SetDeleteKey(key, null);
- }
-
-
-
-
-
- public void SetDeleteKey(string key, string versionId)
- {
- if (!String.IsNullOrEmpty(key))
- {
- if (key.StartsWith("/"))
- {
- key = key.Substring(1);
- }
- Delete.DeleteObject deleteObject = new Delete.DeleteObject();
- deleteObject.key = key;
- if (versionId != null)
- {
- deleteObject.versionId = versionId;
- }
- delete.deleteObjects.Add(deleteObject);
- }
- }
-
-
-
-
- public void SetObjectKeys(List<string> keys)
- {
- if (keys != null)
- {
- foreach (string key in keys)
- {
- SetDeleteKey(key, null);
- }
- }
- }
- public override void CheckParameters()
- {
- if (delete.deleteObjects.Count == 0)
- {
- throw new CosClientException((int)CosClientError.InvalidArgument, "delete keys(null or empty) is invalid");
- }
- base.CheckParameters();
- }
- public override Network.RequestBody GetRequestBody()
- {
- return GetXmlRequestBody(delete);
- }
- }
- }
|