. NET Core Version VII Qiniu SDK use

Source: Internet
Author: User

I. Background of the problem

The company is currently taking part of the business from. NET platform is ready to migrate to. NET core, and is also ready to enable Docker for. NET core deployment, which inevitably encounters some SDKs that are only available under the. NET Framework when the project is migrated, and where. NET core does not. And the seven bull is the one that came across, and before you see Qiniu's official SDK reference on NuGet, it will remind you that the SDK is based on the. NET framework version, which is fine if you deploy under IIS, but if you deploy under Linux, you won't get out of the way, based on this, In order to facilitate the migration of other projects later, a. NET core version of the seven KN SDK, based on the official version of the latest 7.3.

Ii. Modification Instructions

Nonsense not much to say on the code, AH yuck first on the link https://github.com/Hello-Mango/ Mqiniu.core, this is the code I have compiled, and has uploaded nuget (search Mqiniu.core, dare not use the name of Qiniu.core, think the best or official can be out of one)

Modification of the scheme is very simple, the official SDK source syntax with. NET core is actually the same, the final need to modify is the HttpManager.cs file will

false;

Revision changed to

false;

If not modified, will appear error situation, specific what error to forget, this is also I found the solution, if a friend has a better solution, also trouble please inform.

The following is a reference graph:

        

You can see that using Mqiniu.core is not prompted for use. NETFramework

Third, the specific use

  If you want to try it yourself, you can download the official SDK source code for. NET Core Transformation, the official SDK Source address: HTTPS://GITHUB.COM/QINIU/CSHARP-SDK, or you can directly NuGet search Mqiniu.core

  Specific code to use the method can be fully referenced to the official documentation, there is not much to say, this side only give me the test code here

         Publiclist<object> Uploadqiniu () {mac Mac=NewMac (AppSettings.qiniuupload.qiniuyunAK, AppSettings.qiniuupload.qiniuyunSK);/ak SK uses Putpolicy putpolicy /c0>=NewPutpolicy (); Putpolicy.scope=AppSettings.qiniuupload.qiniuyunBucket; stringtoken =Auth.createuploadtoken (Mac, putpolicy.tojsonstring ());//token Generate iformfilecollection files=Request.Form.Files; Config config=NewConfig () {Zone=Zone.zone_cn_east, UseHttps=true            }; varres =Request.Form.ToArray ();Formuploader upload =Newformuploader (config); Httpresult result=NewHttpresult (); List<Object> list =NewList<object>(); foreach(Iformfile fileinchFiles )//Get multiple file list collection {if(file. Length >0)                {                    var_filename =Contentdispositionheadervalue. Parse (file. contentdisposition). FileName. Trim ('"'); var_qiniuname = AppSettings.qiniuupload.prefixPath +"/"+ DateTime.Now.ToString ("yyyymmddhhmmssffffff") +_filename;//Renaming a file plus time stamp stream stream=file.                    Openreadstream (); Result= Upload. Uploadstream (stream, _qiniuname, token,NULL); if(result.) Code = = $) {list. ADD (New{fileName = _filename, Qiniuname = _qiniuname, Uploadtime = datetime.now, Remark = Res. First (p = = P.key = = _filename). value[0] }); }                    Else                    {                        Throw NewException (result. Reftext);//Upload failed error message}}}returnlist; }

Iv. Summary

  Currently used, Qiniu is a very good CDN and object storage platform, the free use of development testing is basically enough, but feel like. NET Core SDK package is best still provided by the official, and then may continue to explore the seven Cow container platform.

  As this is only my personal modification works, has not been a lot of verification, if you find any problem, please contact me.

Mango

Source: http://www.cnblogs.com/OMango/

About yourself: focus. NET desktop development and web background development, start to touch microservices, Docker and other Internet-related

This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph of the statement, and in the article page obvious location, the original link if there is a problem, can mail ([email protected]) Consulting.

. NET Core Version VII Qiniu SDK use

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.