Пример #1
0
        public ActionResult ThumbnailUpload()
        {
            try
            {
                UploadedFile file = RetrieveFileFromRequest();

                if (file.FileName != null)
                {
                    string filename = Path.GetFileName(file.FileName);
                    if (filename != null)
                    {
                          var args = new RIAPP.DataService.ServiceArgs(new Serializer(), this.User);
                          RIAppDemoService svc = new RIAppDemoService(args);
                          using (svc)
                          {
                             svc.SaveThumbnail(file.DataID, file.FileName, file.Contents);
                          }
                    }
                }

                return new HttpStatusCodeResult(200);
            }
            catch (Exception)
            {
                return new HttpStatusCodeResult(400);
            }
        }
Пример #2
0
 public ActionResult ThumbnailDownload(int id)
 {
     try
     {
         var args = new RIAPP.DataService.ServiceArgs(new Serializer(), this.User);
         RIAppDemoService svc = new RIAppDemoService(args);
         using (svc)
         {
             MemoryStream stream = new MemoryStream();
             string fileName = svc.GetThumbnail(id, stream);
             if (string.IsNullOrEmpty(fileName))
                 return new HttpStatusCodeResult(400);
             stream.Position = 0;
             var res = new FileStreamResult(stream, System.Net.Mime.MediaTypeNames.Image.Jpeg);
             res.FileDownloadName = fileName;
             return res;
         }
     }
     catch (Exception)
     {
         return new HttpStatusCodeResult(404);
     }
 }