我该如何将位图对象保存为Amazon S3中的图像?
我已经做好了一切准备,但我的C#编程水平有限,无法完成此操作。
// I have a bitmap iamge
Bitmap image = new Bitmap(width, height);
// Rather than this
image.save(file_path);
// I'd like to use S3
S3 test = new S3();
test.WritingAnObject("images", "testing2.png", image);
// Here is the relevant part of write to S3 function
PutObjectRequest titledRequest = new PutObjectRequest();
titledRequest.WithMetaData("title", "the title")
.WithContentBody("this object has a title")
.WithBucketName(bucketName)
.WithKey(keyName);
可以看到,S3函数只能接受字符串并将其保存为文件的正文。
我该如何编写代码,以便允许我传递位图对象并将其保存为图像?也许是作为流?还是作为字节数组?
非常感谢您的帮助。