Uploading a file to S3 using PreSignedUrl with HttpClient

less than 1 minute read

private static async Task UploadToS3(string filename, string preSignedUrl)
{
    await using var fileStream = File.OpenRead(filename);
    var fileStreamResponse = await new HttpClient().PutAsync(
        new Uri(preSignedUrl),
        new StreamContent(fileStream));
    fileStreamResponse.EnsureSuccessStatusCode();
}

Comments