示例#1
0
        public async Task <IActionResult> PutObject()
        {
            try
            {
                await _ossService.PutObjectAsync(_bucketName, _objectFilePath, _uploadFilePath);

                if (await _ossService.ObjectsExistsAsync(_bucketName, _objectFilePath))
                {
                    return(Json(new ResultObject()
                    {
                        Status = true,
                        Message = $"文件【{_uploadFilePath}】上传成功,路径:{_objectFilePath}"
                    }));
                }
                else
                {
                    return(Json(new ResultObject()
                    {
                        Status = false,
                        Message = $"文件【{_uploadFilePath}】上传失败"
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new ResultObject()
                {
                    Status = false,
                    Message = ex.Message
                }));
            }
        }
        public async Task <IActionResult> PutObject()
        {
            try
            {
                await _OSSService.PutObjectAsync(_bucketName, "PHOTO-1.jpg", @"C:\Users\sysru\Desktop\PHOTO-1.jpg");

                return(Json("OK"));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }