Example #1
0
 public JsonResult UploadChunked(ChunkUploadResult result)
 {
     //this is important because the uploader will make multiple requests for this action.
     //when the upload (for an individual file) is complete, check these two variables for a finished upload.
     if (result.Success && result.FileUploadComplete)
     {
         try
         {
             string path = Server.MapPath("~/App_Data/" + result.OriginalFilename);
             if (System.IO.File.Exists(path))
             {
                 System.IO.File.Delete(path);
             }
             System.IO.File.Move(result.TempFilePath, path);                     //using the posted Filename in the last chunk request to determine final name.
         }
         catch
         {
             //cleanup, remove temp file.
             try
             {
                 if (System.IO.File.Exists(result.TempFilePath))
                 {
                     System.IO.File.Delete(result.TempFilePath);
                 }
             }
             catch { }                     //swallow it. at this point, we're only attempting to cleanup an orphaned file.
         }
     }
     return(Json(new { Success = result.Success, Message = result.Message }));
 }
Example #2
0
        public ChunkedUploader(
            ITwitterAccessor twitterAccessor,
            IUploadQueryGenerator uploadQueryGenerator,
            IMedia media)
        {
            _twitterAccessor      = twitterAccessor;
            _uploadQueryGenerator = uploadQueryGenerator;
            _media  = media;
            _result = new ChunkUploadResult
            {
                Media = _media
            };

            UploadedSegments = new Dictionary <long, byte[]>();
        }