public async Task <AwsResponse> DeleteAsync(IAwsItem item) { AwsResponse awsResponse = new AwsResponse(); try { var deleteObjectRequest = new DeleteObjectRequest { BucketName = BucketPath, Key = item.Key }; await _client.DeleteObjectAsync(deleteObjectRequest); } catch (AmazonS3Exception amazonS3Exception) { awsResponse.Exception = amazonS3Exception; } catch (Exception e) { awsResponse.Exception = e; } return(awsResponse); }
public virtual async Task DeleteAsync(IAwsItem item) { var response = await _bucket.DeleteAsync(item); if (!response.IsSuccess) { throw response.Exception; } }
public virtual async Task <IAwsItem> PutAsync(IAwsItem item) { var response = await _bucket.PutAsync(item); if (response.IsSuccess) { return(response.Item); } else { throw response.Exception; } }
public async Task <AwsItemResponse> PutAsync(IAwsItem item) { AwsItemResponse awsResponse = new AwsItemResponse() { Item = item }; try { var request = new PutObjectRequest { BucketName = BucketPath, Key = item.Key, ContentBody = item.Content, ContentType = item.ContentType }; foreach (string metadataKey in awsResponse.Item.Metadata.Keys) { request.Metadata.Add(metadataKey, awsResponse.Item.Metadata[metadataKey]); } PutObjectResponse objResponse = await _client.PutObjectAsync(request); { awsResponse.RequestId = objResponse.ResponseMetadata.RequestId; awsResponse.HttpStatusCode = objResponse.HttpStatusCode; awsResponse.VersionId = objResponse.VersionId; awsResponse.ETag = objResponse.ETag; awsResponse.LastModified = DateTime.Now; } } catch (AmazonS3Exception amazonS3Exception) { awsResponse.Exception = amazonS3Exception; } catch (Exception e) { awsResponse.Exception = e; } return(awsResponse); }