コード例 #1
0
        internal void ModifyRequest(ObjectsResource.DeleteRequest request)
        {
            // Note the use of ArgumentException here, as this will basically be the result of invalid
            // options being passed to a public method.
            if (IfGenerationMatch != null && IfGenerationNotMatch != null)
            {
                throw new ArgumentException($"Cannot specify {nameof(IfGenerationMatch)} and {nameof(IfGenerationNotMatch)} in the same options", "options");
            }
            if (IfMetagenerationMatch != null && IfMetagenerationNotMatch != null)
            {
                throw new ArgumentException($"Cannot specify {nameof(IfMetagenerationMatch)} and {nameof(IfMetagenerationNotMatch)} in the same options", "options");
            }

            if (Generation != null)
            {
                request.Generation = Generation;
            }
            if (IfGenerationMatch != null)
            {
                request.IfGenerationMatch = IfGenerationMatch;
            }
            if (IfGenerationNotMatch != null)
            {
                request.IfGenerationNotMatch = IfGenerationNotMatch;
            }
            if (IfMetagenerationMatch != null)
            {
                request.IfMetagenerationMatch = IfMetagenerationMatch;
            }
            if (IfMetagenerationNotMatch != null)
            {
                request.IfMetagenerationNotMatch = IfMetagenerationNotMatch;
            }
        }
コード例 #2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            switch (ParameterSetName)
            {
            case ParameterSetNames.FromName:
                // We just use Bucket and ObjectName.
                break;

            case ParameterSetNames.FromObject:
                Bucket     = Object.Bucket;
                ObjectName = Object.Name;
                break;

            default:
                throw UnknownParameterSetException;
            }

            if (!ShouldProcess($"[{Bucket}] {ObjectName}", "Delete Object"))
            {
                return;
            }

            ObjectsResource.DeleteRequest delReq = Service.Objects.Delete(Bucket, ObjectName);
            string result = delReq.Execute();

            if (!string.IsNullOrWhiteSpace(result))
            {
                WriteObject(result);
            }
        }
コード例 #3
0
 internal void ModifyRequest(ObjectsResource.DeleteRequest request)
 {
     if (Generation != null)
     {
         request.Generation = Generation;
     }
 }
コード例 #4
0
        // To delete the file:
        public void Delete(string bucketName)
        {
            ObjectsResource.DeleteRequest deleteRequest = null;

            deleteRequest            = new ObjectsResource.DeleteRequest(_storageService, bucketName, "keyName");
            deleteRequest.OauthToken = _userCredential.Token.AccessToken;
            deleteRequest.Execute();
        }
コード例 #5
0
        public bool DeleteFile(string fileId)
        {
            var newObject = new Google.Apis.Storage.v1.Data.Object()
            {
                Bucket = BucketToUpload,
                Name   = fileId
            };
            string resultStatus;

            try
            {
                var deleteRequest = new ObjectsResource.DeleteRequest(StorageService,
                                                                      BucketToUpload, fileId);
                resultStatus = deleteRequest.Execute();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(true);
        }