Beispiel #1
0
        public async Task <APIResult> UploadFiletoOss(Stream stream, string filename, string localpath)
        {
            APIResult info;
            Regex     regImg = new Regex(".+(.JPEG|.jpeg|.JPG|.jpg|.GIF|.gif|.BMP|.bmp|.PNG|.png)$");

            if (regImg.IsMatch(filename))
            {
                //if (App.SysOS == "Android")
                //{
                //    info = await _commonHelper.UploadFileToOSS(_commonFun.ResizeImage(stream), filename, "");
                //}
                //else
                //{
                string newPath   = _commonFun.GetTempPathForApiToOss(localpath, "RMMTIMAGEVIEW", filename);
                Stream newStream = _commonFun.GetAttachLocal(newPath);
                info = await _commonHelper.UploadFileToOSS(newStream, filename, "");

                _commonFun.DeleteFileForApiToOss(newPath);
                //}
            }
            else
            {
                info = await _commonHelper.UploadFileToOSS(stream, filename, "");
            }

            return(info);
        }