コード例 #1
0
        public FileOssRes ossUpload(FileOssReq req)
        {
            string fileName    = getTmpFileName(req.FileName);
            string fileContent = req.FileContent;

            // 参数检查
            if (string.IsNullOrEmpty(fileName))
            {
                return(newFailedRes(RespCode.FILE_OP_SERVICE_IllegalParameter, "参数不能为空(fileName)"));
            }
            if (string.IsNullOrEmpty(fileContent))
            {
                return(newFailedRes(RespCode.FILE_OP_SERVICE_IllegalParameter, "参数不能为空(fileContent)"));
            }

            // 上传文件内容
            string res = "false";

            try
            {
                res = client.PutObject(fileName, fileContent);
            } catch (Exception ex)
            {
                ErrorLog(ex);
                return(newFailedRes(RespCode.FILE_OP_SERVICE_InternalError, ex.Message));
            }

            //
            return(newSuccessRes(res));
        }
コード例 #2
0
        public FileOssRes ossStore(FileOssReq req)
        {
            string fileName = getTmpFileName(req.FileName);

            // 参数检查
            if (string.IsNullOrEmpty(fileName))
            {
                return(newFailedRes(RespCode.FILE_OP_SERVICE_IllegalParameter, "参数不能为空(fileName)"));
            }

            string sourceObject = fileName;
            string targetObject = fileName.Substring(5);
            string res          = "false";

            try
            {
                res = client.CopyObject(sourceObject, targetObject);
            }
            catch (Exception ex)
            {
                ErrorLog(ex);
                return(newFailedRes(RespCode.FILE_OP_SERVICE_InternalError, ex.Message));
            }
            return(newSuccessRes(res));
        }
コード例 #3
0
        public FileOssRes ossDownload(FileOssReq req)
        {
            string fileName = req.FileName;

            // 参数检查
            if (string.IsNullOrEmpty(fileName))
            {
                return(newFailedRes(RespCode.FILE_OP_SERVICE_IllegalParameter, "参数不能为空(fileName)"));
            }

            // 获取文件内容
            string fileContent = null;

            try
            {
                fileContent = client.GetObject(fileName);
            } catch (Exception ex)
            {
                ErrorLog(ex);
                return(newFailedRes(RespCode.FILE_OP_SERVICE_InternalError, ex.Message));
            }
            //
            return(newSuccessRes(fileContent));
        }
コード例 #4
0
 public FileOssRes ossDelete([FromBody] FileOssReq req)
 {
     return(client.ossDelete(req));
 }
コード例 #5
0
 public FileOssRes ossDownload([FromBody] FileOssReq req)
 {
     return(client.ossDownload(req));
     //return new FileOssRes("0002", "download-res", "");
 }
コード例 #6
0
 public FileOssRes ossUpload([FromBody] FileOssReq req)
 {
     return(client.ossUpload(req));
     //return new FileOssRes("0001","upload-res","");
 }