Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5931869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:45:19+00:00 2026-05-22T14:45:19+00:00

I have develop a ASP.NET (C#) application to store the images and videos into

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:45:21+00:00Added an answer on May 22, 2026 at 2:45 pm

    There’s a lot of code to get up and running with Amazon’s web service. I think this part of code is what you need, you might not be setting the right content type:

    // Setup some metadata to indicate the content type 
            MetadataEntry myContentType = new MetadataEntry();
            myContentType.Name = "ContentType";
            myContentType.Value = FileUpload1.PostedFile.ContentType;
    

    Here’s the full code: Enjoy.

    `private const string accessKeyId = "REMOVED";
        private const string secretAccessKey = "REMOVED";
        private static DateTime GetTimeStamp(DateTime myTime)
        {
            DateTime myUniversalTime = myTime.ToUniversalTime();
            DateTime myNewTime = new DateTime(myUniversalTime.Year,
            myUniversalTime.Month, myUniversalTime.Day,
            myUniversalTime.Hour, myUniversalTime.Minute,
            myUniversalTime.Second, myUniversalTime.Millisecond);
    
            return myNewTime;
        }
        private static string GetSignature(string secretAccessKey, string strOperation, DateTime myTime)
        {
            Encoding myEncoding = new UTF8Encoding();
    
            // Create the source string which is used to create the digest
            string mySource = "AmazonS3" + strOperation + FormatTimeStamp(myTime);
    
            // Create a new Cryptography class using the 
            // Secret Access Key as the key
            HMACSHA1 myCrypto = new HMACSHA1(myEncoding.GetBytes(secretAccessKey));
    
            // Convert the source string to an array of bytes
            char[] mySourceArray = mySource.ToCharArray();
            // Convert the source to a UTF8 encoded array of bytes
            byte[] myUTF8Bytes = myEncoding.GetBytes(mySourceArray);
            // Calculate the digest 
            byte[] strDigest = myCrypto.ComputeHash(myUTF8Bytes);
            return Convert.ToBase64String(strDigest);
        }
        private static string FormatTimeStamp(DateTime myTime)
        {
            DateTime myUniversalTime = myTime.ToUniversalTime();
            return myUniversalTime.ToString("yyyy-MM-dd\\THH:mm:ss.fff\\Z", System.Globalization.CultureInfo.InvariantCulture);
        }
        /// <summary>
        /// Upload Images.
        /// </summary>
        /// <param name="a">Ex. FileUpload1.PostedFile.ContentType</param>
        /// <param name="b">Ex. FileUpload1.PostedFile.FileName</param>
        /// <param name="c">Ex. FileUpload1.FileBytes</param>
        /// <param name="d">Ex. FileUpload1.FileBytes.Length</param>
        /// <param name="id">The ID for this Product Group</param>
        public void UploadImage_ProductGroup(string a, string b, byte[] c, long d, int id)
        {
            AmazonS3 myS3 = new AmazonS3();
            DateTime myTime = DateTime.Now;
    
            // Create a signature for this operation
            string strMySignature = GetSignature(
            secretAccessKey,
            "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;
    
            // Setup some metadata to indicate the content type 
            MetadataEntry myContentType = new MetadataEntry();
            myContentType.Name = "ContentType";
            myContentType.Value = a;
    
            MetadataEntry[] myMetaData = new MetadataEntry[1];
            myMetaData[0] = myContentType;
    
            //Format the file name to prepend thumbnail before the file extension.
          /*  int lastIndex = b.LastIndexOf('.');
            string fileName = b.Remove(lastIndex);
            string ext = b.Remove(0, lastIndex);
            string thumbPath = string.Format("images/public/{0}thumb{1}",fileName,ext);
            //Resize the thumbnail
            */
    
    
    
            // Finally upload the object
            PutObjectResult myResult = myS3.PutObjectInline(
                "mywebsite",
            "images/public/" + b,
                myMetaData,
                c,
                d,
                myGrants,
                StorageClass.STANDARD,
                true,
                accessKeyId,
                GetTimeStamp(myTime),
                true,
                strMySignature, null
            );`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have develop a small web application in asp.net (c#) for uploading files into
If i have to develop a small CRM application, why would i choose ASP.NET
I am using asp.net MVC to develop an application that will have ajax interactions.
Im trying to develop my first ASP.NET MVC web app and have run into
i have develop a small asp.net web application in this i have a in
I have develop small Asp.net MVC3 application using Telerik rad Controls with in that
i have develop a small mvc3 application using Telerik Extension for asp.net mvc3 in
I want to develop a webapp using ASP.NET but it have to use some
I have to develop an ASP.NET MVC3 application in C# and Razor that has
I have to develop an appliction (Asp.Net - maybe MVC) that would be integrated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.