【发布时间】:2011-05-20 06:14:49
【问题描述】:
我开发了一个 ASP.NET (C#) 应用程序来将图像和视频存储到 Amazon S3 中。图像上传正常,但当我尝试上传视频时,它会在 Amazon S3 中保存为图像格式。
有谁知道问题出在哪里或如何上传视频?
private void Amzon(string imageName,string imgcontenttype,int imglength,byte[] fileData)
{
AmazonS3 myS3 = new AmazonS3();
DateTime myTime = DateTime.Now;
// Create a signature for this operation
string strMySignature = S3Helper.GetSignature(mySecretAccessKeyId, "PutObjectInline", myTime);
// Create a new Access grant for anonymous users.
Grant myGrant = new Grant();
Grant[] myGrants = new Grant[1];
// Setup Access control, allow Read access to all
Group myGroup = new Group();
myGroup.URI = "http://acs.amazonaws.com/groups/global/AllUsers";
myGrant.Grantee = myGroup;
myGrant.Permission = Permission.READ;
myGrants[0] = myGrant;
string key = imageName;
// Setup some metadata to indicate the content type
MetadataEntry myContentType = new MetadataEntry();
myContentType.Name = "ContentType";
myContentType.Value = imgcontenttype;
MetadataEntry[] myMetaData = new MetadataEntry[1];
myMetaData[0] = myContentType;
// Finally upload the object
PutObjectResult myResult = myS3.PutObjectInline(
bucketname,
key,
myMetaData,
fileData,
imglength,
myGrants,
StorageClass.STANDARD,
true,
myAWSAccessKeyId,
S3Helper.GetTimeStamp(myTime),
true,
strMySignature, null
);
// Print out the results.
if (myResult != null)
{
cn.Open();
Url = "https://s3.amazonaws.com/" + bucketname + "/" + key;
string Query = "Insert into S3Image(ImageName,ImageUrl)Values('" + key + "','" + Url + "')";
SqlCommand cmd = new SqlCommand(Query, cn);
cmd.ExecuteNonQuery();
cn.Close();
//MyPrint("ETag: " + myResult.ETag);
MyPrint("<img src=https://s3.amazonaws.com/" + bucketname + "/" + key);
}
}
谢谢。
【问题讨论】:
-
您要上传什么格式的视频?视频的扩展名是什么?你能给我们看一些代码吗?
-
感谢您的回复,我已尝试上传 .mp4 格式文件
-
你能给我们看一些代码吗?如果没有它,很难弄清楚问题可能是什么。
-
嗨,我已将我的代码粘贴到我上面的问题中,请找到该代码..
-
您好,对此问题有任何想法,请告诉我......