Beispiel #1
0
        public Task Remove(FileUse fileUse, string fileId)
        {
            string s3Key = FileServiceUtilities.GetKey(fileUse, fileId);
            var    deleteObjectRequest = new DeleteObjectRequest
            {
                BucketName = _s3Config.BucketName,
                Key        = s3Key
            };

            return(_retryPolicy.ExecuteAsync(() => _s3Client.DeleteObjectAsync(deleteObjectRequest)));
        }
Beispiel #2
0
        public async Task <string> Add(FileUse fileUse, string fileId, string contentType, Stream stream)
        {
            string s3Key            = FileServiceUtilities.GetKey(fileUse, fileId);
            var    putObjectRequest = new PutObjectRequest
            {
                BucketName      = _s3Config.BucketName,
                Key             = s3Key,
                InputStream     = stream,
                ContentType     = contentType,
                CannedACL       = S3CannedACL.Private,
                AutoCloseStream = false
            };

            await _retryPolicy.ExecuteAsync(() => _s3Client.PutObjectAsync(putObjectRequest)).ConfigureAwait(false);

            return(FileServiceUtilities.GetCdnFileUrl(_s3Config.CdnUrl, s3Key));
        }