How to convert the base64 encoding of a post image to stream

Source: Internet
Author: User
Private   Void Page_load ( Object Sender, system. eventargs E)
{
String URL = Request. querystring [ " Photo " ];
Byte [] BYT = Convert. frombase64string (URL );
Response. Clear ();
Response. contenttype =   " Image/JPEG " ;
Response. binarywrite (BYT );
Response. End ();
}

You can obtain a base64 encoded string from the request, and then convert the image using the convert. frombase64string method.
It is a binary array and then displayed on the page through response

But how can we convert an image into a livestream?

Base64-encoded
Byte[] BYT=Convert. frombase64string (URL );
Stream stream = new memorystream (html2bytes );

If base64 encoding is not performed, assume that it is a piece of plain text.
Stream stream = NULL;

String html = "dsf3d43dsds4158dfdsfdsfsadfdsfjhgkhgkj678gdrkl65kjf94jdf8f8 this is not base64 encoded ";
Byte [] html2bytes = system. Text. encoding. ASCII. getbytes (HTML );

Stream = new memorystream (html2bytes );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.