Example #1
0
        private async Task <BaseWebApiResponse <string> > processUploadFiles()
        {
            var provi = new MultipartFormDataMemoryStreamProvider();

            await Request.Content.ReadAsMultipartAsync(provi);

            var response = new BaseWebApiResponse <string>();

            // var ServiceId = provi.FormData.Get("ImageService");
            // Check if files are on the request.
            if (!provi.FileStreams.Any())
            {
                throw new Exception("没有任何文件!");
            }
            foreach (KeyValuePair <string, Stream> file in provi.FileStreams)
            {
                var dotIndex = file.Key.LastIndexOf('.');
                if (dotIndex <= 0)
                {
                    throw new Exception("文件格式不正确");
                }
                var suffix = file.Key.Substring(dotIndex);
                if (!ListPicSuffixs.Contains(suffix))
                {
                    throw new Exception("文件格式不正确");
                }
                response.Result = ImageManagerService.GetService().Save(file.Value);
            }
            provi.FileStreams.Clear();
            return(response);
        }
Example #2
0
        public IHttpActionResult Delete(BaseWebApiRequest <string> request)
        {
            var response = new BaseWebApiResponse <object>();

            //  PictureService.Delete(request.Param);
            return(Ok(response));
        }