LitS3.S3Service.DeleteObject C# (CSharp) Method

DeleteObject() public method

Deletes the object in the specified bucket with the specified key.
public DeleteObject ( string bucketName, string key ) : void
bucketName string
key string
return void
        public void DeleteObject(string bucketName, string key)
        {
            new DeleteObjectRequest(this, bucketName, key).GetResponse().Close();
        }

Usage Example

Example #1
0
        public ActionResult Delete(int photoItemID)
        {
            _mu = MembershipWrapper.GetUser();

            _pitm = new PhotoItem(photoItemID);

            if (_mu == null || _pitm.CreatedByUserID != Convert.ToInt32(_mu.ProviderUserKey))
                return RedirectToAction("Index");

            var s3 = new S3Service
            {
                AccessKeyID = AmazonCloudConfigs.AmazonAccessKey,
                SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey
            };

            _pitm.Delete();

            if (string.IsNullOrEmpty(_pitm.FilePathStandard)) return RedirectToAction("Index");
            // delete the existing photos
            try
            {
                if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathStandard))
                {
                    s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathStandard);
                }

                if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathRaw))
                {
                    s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathRaw);
                }

                if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathThumb))
                {
                    s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathThumb);
                }
            }
            catch
            {
                // whatever
            }

            return RedirectToAction("Index");
        }
All Usage Examples Of LitS3.S3Service::DeleteObject