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)); }
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)); }
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)); }