Exemplo n.º 1
0
        public static async Task <PutObjectResponse> PutObjectDataAsync(this IObjectClient client, string bucketName, string objectKey, byte[] data, Action <PutObjectRequest> config = null, CancellationToken token = default)
        {
            Validator.RequireNotNull(client, nameof(client));
            Validator.RequireNotNull(bucketName, nameof(bucketName));
            Validator.RequireNotNull(objectKey, nameof(objectKey));

            using (MemoryStream ms = new MemoryStream(data))
                return(await client.PutObjectAsync(bucketName, objectKey, ms, config, token).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        public static async Task <PutObjectResponse> PutObjectFileAsync(this IObjectClient client, string bucketName, string objectKey, string file, Action <PutObjectRequest> config = null, CancellationToken token = default)
        {
            Validator.RequireNotNull(client, nameof(client));
            Validator.RequireNotNull(bucketName, nameof(bucketName));
            Validator.RequireNotNull(objectKey, nameof(objectKey));

            if (!File.Exists(file))
            {
                throw new FileNotFoundException("The file does not exist.", file);
            }

            using (FileStream fs = File.OpenRead(file))
                return(await client.PutObjectAsync(bucketName, objectKey, fs, config, token).ConfigureAwait(false));
        }
Exemplo n.º 3
0
 public Task <PutObjectResponse> PutObjectAsync(string bucketName, string objectKey, Stream?data, Action <PutObjectRequest>?config = null, CancellationToken token = default)
 {
     return(_objectClient.PutObjectAsync(bucketName, objectKey, data, config, token));
 }