public HttpResponseMessage UploadThumbnail(HttpRequestMessage request)
        {
            try
            {
                UploadedFile file = RetrieveFileFromRequest(request);

                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.SaveThumbnail2(file.DataID, file.FileName, file.Content.CopyToAsync);
                        }
                    }
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                var response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
                throw new HttpResponseException(response);
            }
        }
 public HttpResponseMessage DownloadThumbnail(HttpRequestMessage request, string 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(int.Parse(id), stream);
             if (string.IsNullOrEmpty(fileName))
                 return Request.CreateResponse(HttpStatusCode.NotFound);
             stream.Position = 0;
             HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
             result.Content = new StreamContent(stream);
             result.Content.Headers.ContentType = new MediaTypeHeaderValue(System.Net.Mime.MediaTypeNames.Image.Jpeg);
             result.Content.Headers.Add("Content-Disposition", new string[]{string.Format("attachment; filename=\"{0}\"", fileName) });
             return result;
         }
     }
     catch (Exception ex)
     {
         var response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
         throw new HttpResponseException(response);
     }
 }