public static Task <string> UploadTextAsync(this S3Helper s3, string bucketName, string key, string text, string keyId = null, Encoding encoding = null, CancellationToken cancellationToken = default(CancellationToken)) => s3.UploadStreamAsync(bucketName: bucketName, key: key, inputStream: text.ToMemoryStream(encoding), contentType: "text/plain", cancellationToken: cancellationToken);
public static Task <string> UploadJsonAsync <T>(this S3Helper s3, string bucketName, string key, T content, Newtonsoft.Json.Formatting formatting = Newtonsoft.Json.Formatting.Indented, string keyId = null, Encoding encoding = null, CancellationToken cancellationToken = default(CancellationToken)) => s3.UploadStreamAsync(bucketName: bucketName, key: key, inputStream: content.JsonSerialize(formatting).ToMemoryStream(encoding), contentType: "text/plain", cancellationToken: cancellationToken);
public static async Task CreateDirectory(this S3Helper s3, string bucketName, string path, CancellationToken cancellationToken = default(CancellationToken)) { var key = $"{path.Trim('/')}/"; if (await s3.ObjectExistsAsync(bucketName: bucketName, key: key)) { return; //already exists } var stream = new MemoryStream(new byte[0]); var obj = await s3.UploadStreamAsync(bucketName : bucketName, key : key, inputStream : stream, cancellationToken : cancellationToken); }