Windows Azure Series--upload pictures with Azure + Web API

Source: Internet
Author: User

1. Create 1 Azure accounts, log in and create 1 azurestorage, and the lower left manage access will see primary access key and storage account, remember their location, Wait for the configuration to be configured in Web. config.


2. Create Web.api project, upload the image code:


[HttpPost] public async task
Contains two action,postfile and Azureimageurls, which are used to receive a post-file object, which is used to get a URI from Azure back to the client.

First, when uploading, you need to set this line of code:

Publicaccess = Blobcontainerpublicaccesstype.blob

If not set, the default access permission is not to directly access the BLOB picture on the client, so the picture is not displayed.


Second, this line of code needs to be set in the API when the client obtains the URI:

HttpContext.Current.Response.AddHeader ("Access-control-allow-origin", "*");


3. Web Config

<appSettings>        <add key= "azureimagestorage" value= "defaultendpointsprotocol=http; Accountname=name; Accountkey=yourkey "/>  </appSettings>
It is important to note that there is no space allowed in value. This link string is the standard form, and more azure link strings can be referenced by:

Https://www.connectionstrings.com/windows-azure/


4. Recommended download Cloud Berry This kind of FTP-like management tool, easy to view the uploaded pictures, if the wrong pass can be deleted:

Http://www.cloudberrylab.com


5. Client HTML implementation:

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.