예제 #1
0
파일: AwsHelper.cs 프로젝트: lacti/Lz
 public void DeleteFile(string bucketName, string cloudPath)
 {
     S3.DeleteObject(new DeleteObjectRequest
     {
         BucketName = bucketName,
         Key        = cloudPath,
         Timeout    = -1
     });
 }
        /// <summary>
        /// Deletes the specified file.
        /// </summary>
        /// <param name="path">Path of the file to delete.</param>
        public void DeleteFile(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            path = MapPath(path);
            path = path.Substring(this.BucketName.Length + 1);
            var deleteRequest = new DeleteObjectRequest()
            {
                Key        = path,
                BucketName = this.BucketName,
            };

            S3.DeleteObject(deleteRequest);
        }
        public async Task <bool> DeleteDoc(string id)
        {
            HeaderModel header = SQLData.GetHeaderById(id);

            if (header != null)
            {
                if (String.IsNullOrEmpty(header.Attachment))
                {
                    SQLData.DeleteDoc(header.Attachment);
                    S3.DeleteObject(header.Attachment);
                }

                SQLData.DeleteDoc(id);
                S3.DeleteObject(id);
            }

            return(true);
        }
        /// <summary>
        /// Deletes the specified directory and, optionally, sub-directories.
        /// </summary>
        /// <param name="path">Path of the directory to delete.</param>
        /// <param name="recursive">Indicates whether to delete sub directories.</param>
        public void DeleteDirectory(string path, bool recursive)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            path = FixPath(path);
            path = path.Substring(this.BucketName.Length + 1) + "/";

            var deleteRequest = new DeleteObjectRequest()
            {
                Key        = path,
                BucketName = this.BucketName,
            };

            S3.DeleteObject(deleteRequest);
        }