chenpeng

基于OSS帮助类的C#上传对象存储的方法获取图片地址
通过此方法可用获取图片地址: /// <summary> /// 上传ALY ...
扫描右侧二维码阅读全文
31
2019/08

基于OSS帮助类的C#上传对象存储的方法获取图片地址

通过此方法可用获取图片地址:

 /// <summary>
        /// 上传ALY
        /// </summary>
        /// <param name="urlsrc">base64</param>
        /// <param name="loadfileName">后缀</param>
        /// <returns>阿里图片路径</returns>
        [HttpPost]
        public string Upload(string urlsrc, string loadfileName)
        {
            string bucketName = "";
            string fileName = Helper.GetInvitationCode(2, "Bank");
            int index = urlsrc.IndexOf(",");
            urlsrc = urlsrc.Substring(index + 1);

            if (loadfileName != ".jpg" && loadfileName != ".png" && loadfileName != ".jpeg" && loadfileName != ".bmp" && loadfileName != ".PNG")
            {
                return null;
            }
            OssALiHelper aLiHelper = new OssALiHelper("", "", "", bucketName);
            //上传一张图片
            var pushRes = aLiHelper.PushImg(urlsrc, fileName);
            //获取临时URL 超时时间30秒
            var url = aLiHelper.GetFileUrl(fileName);
            if (url != null)
            {
                return url;
            }
            else
            {
                return null;
            }
Last modification:August 31st, 2019 at 05:47 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment