Beispiel #1
0
        /// <summary>
        /// Reupload file from the stream.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public ReuploadFileResponse Put(ReuploadFileRequest request)
        {
            if (request.Data.Id.Equals(Guid.Empty))
            {
                throw new CmsApiValidationException("MediaFile ID must be provided");
            }

//            var file = repository.AsQueryable<MediaFile>().FirstOrDefault(f => f.Id == request.Data.Id);
//            if (file == null)
//            {
//                throw new CmsApiValidationException("File with specified ID could not be found");
//            }
            // Create and save history item
//            mediaFileService.SaveMediaFile((MediaFile)file.CreateHistoryItem());

            var savedFile = mediaFileService.UploadFileWithStream(
                Module.MediaManager.Models.MediaType.File,
                Guid.Empty,
                request.Data.FileName,
                request.Data.FileStream.Length,
                request.Data.FileStream,
                request.Data.WaitForUploadResult,
                string.Empty,
                string.Empty,
                request.Data.Id);

//            mediaFileService.SaveMediaFile(savedFile);
            return(new ReuploadFileResponse {
                Data = savedFile.Id
            });
        }
Beispiel #2
0
        /// <summary>
        /// Reupload file from the stream.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public ReuploadFileResponse Put(ReuploadFileRequest request)
        {
            if (request.Data.Id.Equals(Guid.Empty))
            {
                throw new CmsApiValidationException("MediaFile ID must be provided");
            }

//            var file = repository.AsQueryable<MediaFile>().FirstOrDefault(f => f.Id == request.Data.Id);
//            if (file == null)
//            {
//                throw new CmsApiValidationException("File with specified ID could not be found");
//            }
            // Create and save history item
//            mediaFileService.SaveMediaFile((MediaFile)file.CreateHistoryItem());

            var savedFile = mediaFileService.UploadFileWithStream(
                Module.MediaManager.Models.MediaType.File,
                Guid.Empty,
                request.Data.FileName,
                request.Data.FileStream.Length,
                request.Data.FileStream,
                request.Data.WaitForUploadResult,
                string.Empty,
                string.Empty,
                request.Data.Id);

//            mediaFileService.SaveMediaFile(savedFile);
            return new ReuploadFileResponse { Data = savedFile.Id };
        }