我将图像成功上传到Amazon S3,但是当我查看图像时它没有显示任何内容。
我的观点:
public JsonResult Upload(SocialJobMediaModel socialJobMediaModel)
{
var imagePathErrorMessage = new ImagePathErrorMessage();
if (Request.Files.Count > 0)
{
_log = GetProcessorLogger("CompanyXcodes", "CompanyXcodes", 1);
StageMediaFileProcessor stageMediaFileProcessor = new StageMediaFileProcessor(_log);
imagePathErrorMessage = stageMediaFileProcessor.UploadMediaFilesToS3(Request.Files[0].InputStream, Request.Files[0].FileName,"1234");
}
}
public void BulkUpload(Stream stream, string fileName, NameValueCollection metadata, ILogger log = null)
{
// Prepare request
if (string.IsNullOrEmpty(AwsRegion))
{
Client = new AmazonS3Client(_awsAccessKey, _awsSecretKey);
}
else
{
var regionEndPoint = RegionEndpoint.GetBySystemName(AwsRegion);
Client = new AmazonS3Client(regionEndPoint);
}
var tu = new TransferUtility(Client);
var request = new TransferUtilityUploadRequest
{
InputStream = stream,
Key = KeyPath + fileName,
BucketName = BucketName,
CannedACL = S3CannedACL.PublicRead,
};
if (metadata != null)
{
foreach (var metaDataKey in metadata.AllKeys)
{
request.Metadata.Add(metaDataKey, metadata[metaDataKey]);
}
}
// Set up progress logging (if logger provided)
if (log != null)
request.UploadProgressEvent += (sender, e) =>
{
if (e.PercentDone % 10 == 0)
log.LogInfo("Uploaded {0} of {1} bytes ({2} %)", e.TransferredBytes, e.TotalBytes, e.PercentDone);
};
// Upload (synchronous)
tu.Upload(request);
}
我能够成功上传图片,但是当我查看图片时,它显示无关。任何人都可以帮我这个
我尝试上传文件路径而不是输入流,但它会抛出错误