gpt4 book ai didi

c# - 如何上传内存文件到amazon S3?

转载 作者:太空狗 更新时间:2023-10-29 22:32:40 26 4
gpt4 key购买 nike

我想从我的 memoryStream 上传一个文件到 amazon S3 服务器。

代码如下:

public static bool memUploadFile(AmazonS3 client, MemoryStream memFile, string toPath)
{

try
{
Amazon.S3.Transfer.TransferUtility tranUtility = new Amazon.S3.Transfer.TransferUtility(client);
tranUtility.Upload(filePath, toPath.Replace("\\", "/"));

return true;
}
catch (Exception ex)
{
return false;
}

}

然后错误说,

“'Amazon.S3.Transfer.TransferUtility.Uplaod(string,string)' 的最佳重载方法匹配有一些无效参数”

最佳答案

查看Upload Method (stream, bucketName, key)

public static bool memUploadFile(AmazonS3 client, MemoryStream memFile, string toPath)
{
try
{
using(Amazon.S3.Transfer.TransferUtility tranUtility =
new Amazon.S3.Transfer.TransferUtility(client))
{
tranUtility.Upload(memFile, toPath.Replace("\\", "/"), <The key under which the Amazon S3 object is stored.>);

return true;
}
}
catch (Exception ex)
{
return false;
}
}

关于c# - 如何上传内存文件到amazon S3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19187964/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com