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 496819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:43:20+00:00 2026-05-13T05:43:20+00:00

I have a test that uploads a bytearray (image – jpg) to our database

  • 0

I have a test that uploads a bytearray (image – jpg) to our database (Sql Server FileStream) and then retrieves it through a HttpHandler. Next I compare the two.

Now, they are almost the same except for the first four bytes…

What’s in those first four bytes?

First byteArray : 255, 216, 255, 224, from here on they are the same

Second byteArray: 63, 63, 63, 63 …

When retrieved from the db by the handler, the string is converted to a bytearray like this

Update

StringWriter writer;
SimpleWorkerRequest worker;

writer = new StringWriter();
worker = new SimpleWorkerRequest(page, query, writer);
HttpRuntime.ProcessRequest(worker);
writer.Flush();

var  encoding=new ASCIIEncoding();
var blob = encoding.GetBytes(writer.GetStringBuilder().ToString());

return blob;
  • 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-13T05:43:20+00:00Added an answer on May 13, 2026 at 5:43 am

    If you want to know why this happens, this is because ASCII encoding can’t handle characters above 128. The first four characters are converted to ‘?’.

    Since you have an image in the byte array, you shouldn’t try to convert it to text in order to compare the two arrays. For comparison’s sake, you should iterate through all bytes and print their values. It would be better to use hex notation for this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Visual Studio 2008 sp1 test suite web test that uploads
I have a feature that uploads a user submitted CSV file into my database
I have a script that uploads a file and then moves it to a
Scenario I have a Node.JS service (written using ExpressJS ) that accepts image uploads
Have made backup script that does well: makes backup zip-file and then uploads it
I have a test that is successful (among other things) if a certain callback
I have a test file that contains tests taking quite a lot of time
I have a unit test that creates a mock calls my method to be
I have a test file that has many lines, each line looks something like:
I have a unit test that tests if an Exception is throw, but this

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.