I have develop a ASP.NET (C#) application to store the images and videos into Amazon S3. Images are being uploaded fine but when i try to upload videos it saves as an image format in Amazon S3.
Does anyone know what the issue is or how to I can upload videos?
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);
}
}
Thank you.