我開發了一個ASP.NET(C#)應用程序,用於將圖像和視頻存儲到Amazon S3中。圖片上傳正常,但是當我嘗試上傳視頻時,它將其保存爲Amazon S3中的圖像格式。使用ASP.NET C將視頻文件上傳到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);
}
}
謝謝。
你試圖上傳什麼格式的視頻?視頻的擴展名是什麼?你能告訴我們一些代碼嗎? – 2011-05-20 06:16:37
感謝您給予迴應,我已嘗試.mp4檔案文件上傳 – 2011-05-20 06:24:03
您是否能夠向我們展示一些代碼?如果沒有這個問題,要弄清楚問題可能會有點困難。 – 2011-05-20 06:25:43