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

  • Home
  • SEARCH
  • 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 6376223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:43:03+00:00 2026-05-25T01:43:03+00:00

I am trying to upload an image to Amazon S3 but before that I

  • 0

I am trying to upload an image to Amazon S3 but before that I am resizing the image. For resizing I have to pass the stream objects and at one point (line commented as //Error) I am getting ‘Stream does not support writing.’ Exception. Please help.

 public ActionResult AddPost(AddPost post)
    {
        Guid guid = new Guid();
        AccountController ac=new AccountController();

        string randomId = guid.ToString();

        PutAttributesRequest putAttributesAction = new PutAttributesRequest().WithDomainName("ThisIsMyEXDomainPosts").WithItemName(randomId);

        List<ReplaceableAttribute> attrib = putAttributesAction.Attribute;

        System.IO.Stream stream;

        System.IO.StreamReader sr = new System.IO.StreamReader(post.imageFileAddress.ToString());


        sr.ReadToEnd();

        stream = sr.BaseStream;

        Amazon.S3.Model.PutObjectRequest putObjectRequest = new Amazon.S3.Model.PutObjectRequest();

        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);

        System.Drawing.Image imgResized = ResizeImage(img, 640, 800);

        System.IO.MemoryStream mstream = new System.IO.MemoryStream();

        imgResized.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg);

        mstream.WriteTo(stream);//Error

        putObjectRequest.WithBucketName("TIMEXImages");
        putObjectRequest.CannedACL = Amazon.S3.Model.S3CannedACL.PublicRead;
        putObjectRequest.Key = randomId + "_0.jpg";
        putObjectRequest.InputStream = stream;

        Amazon.S3.Model.S3Response s3Response = as3c.PutObject(putObjectRequest);
        s3Response.Dispose();

        //Uploadig the Thumb

        System.Drawing.Image imgThumb = ResizeImage(img, 80, 100);

        imgThumb.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg);

        mstream.WriteTo(stream);

        putObjectRequest.WithBucketName("MyProjectImages");
        putObjectRequest.CannedACL = Amazon.S3.Model.S3CannedACL.PublicRead;
        putObjectRequest.Key = randomId + ".jpg";
        putObjectRequest.InputStream = stream;

        Amazon.S3.Model.S3Response s3Response2 = as3c.PutObject(putObjectRequest);
        s3Response2.Dispose();


        //Closing all opened streams
        sr.Close();

        stream.Close();

        mstream.Close();



        //Adding to SimpleDB
        attrib.Add(new ReplaceableAttribute().WithName("category").WithValue(post.category));
        attrib.Add(new ReplaceableAttribute().WithName("description").WithValue(post.description));
        attrib.Add(new ReplaceableAttribute().WithName("favoriteCount").WithValue("0"));
        attrib.Add(new ReplaceableAttribute().WithName("imageThug").WithValue(randomId));
        attrib.Add(new ReplaceableAttribute().WithName("title").WithValue(post.title));
        attrib.Add(new ReplaceableAttribute().WithName("userId").WithValue(ac.GetLoggedInUserId()));

        sdb.PutAttributes(putAttributesAction);




        return View();
    }
  • 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-25T01:43:04+00:00Added an answer on May 25, 2026 at 1:43 am

    It seems like the BaseStream of a StreamReader is read only – which makes sense. Why do you need to re-use this stream in the first place though? Just use the memory stream directly:

    mstream.Position = 0;
    putObjectRequest.InputStream = mstream;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Form I am trying to upload my image but every time
i am trying to upload an image from a jsp page using servlet. but
I'm trying to upload image to Amazon S3 with this Ruby code: require 'net/http/post/multipart'
I have ~16,000 images I'm trying to upload to Amazon. Right now, they're on
I am trying to upload image on web server, but whenever it tries it
I need some advice and guide line. I am trying to upload image into
Greetings, I'm trying to upload an image on my Android device. I have the
I am trying to upload image on server, below is script that I found
I'm trying to upload an image via the Django admin and then view that
I am trying to upload the image using the webservices and Base64string. But each

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.