Beispiel #1
0
        private FileManagerResponse?UploadPrivate(string path, IList <IFormFile> files, string action)
        {
            if (files.Any(x => x.Length > fileManagerConfiguration.MaximumUploadSize))
            {
                return(null);
            }

            var response = operation.Upload(path, files, action, null);

            return(response);
        }
 public IActionResult Upload(string path, IList<IFormFile> uploadFiles, string action)
 {
     FileManagerResponse uploadResponse;
     uploadResponse = operation.Upload(path, uploadFiles, action, null);
     if (uploadResponse.Error != null)
     {
        Response.Clear();
        Response.ContentType = "application/json; charset=utf-8";
        Response.StatusCode = Convert.ToInt32(uploadResponse.Error.Code);
        Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = uploadResponse.Error.Message;
     }
     return Content("");
 }
 // Processing the Upload operation
 public IActionResult Upload(string path, IList <IFormFile> uploadFiles, string action)
 {
     // Here we have restricted the upload operation for our online samples
     if (Response.HttpContext.Request.Host.Value == "ej2.syncfusion.com")
     {
         Response.Clear();
         Response.ContentType = "application/json; charset=utf-8";
         Response.StatusCode  = 403;
         Response.HttpContext.Features.Get <IHttpResponseFeature>().ReasonPhrase = "File Manager's upload functionality is restricted in the online demo. If you need to test upload functionality, please install Syncfusion Essential Studio on your machine and run the demo";
     }
     // Use below code for performing upload operation
     else
     {
         FileManagerResponse uploadResponse;
         //Invoking upload operation with the required paramaters
         // path - Current path where the file is to uploaded; uploadFiles - Files to be uploaded; action - name of the operation(upload)
         uploadResponse = operation.Upload(path, uploadFiles, action, null);
     }
     return(Content(""));
 }
        public async Task <IActionResult> Upload([FromForm] FileManagerDirectoryContent args, IList <IFormFile> uploadFiles)
        {
            //if(false)
            //{
            //    Response.Clear();
            //    Response.ContentType = "application/json; charset-utf8";
            //    Response.StatusCode = 403;
            //    Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "";
            //}
            FileManagerResponse uploadResponse = opration.Upload(args.Path, uploadFiles, args.Action, null);

            if (uploadResponse.Error == null)
            {
                return(NoContent());
            }
            else
            {
                return(BadRequest(uploadResponse.Error.Message));
            }
        }
Beispiel #5
0
        public FileManagerResponse UploadFile(string path, IList <IFormFile> uploadFiles, string action)
        {
            long filesLength = 0;

            //add ServerFile entity for each file uploaded
            foreach (var file in uploadFiles)
            {
                path = Path.Combine(path, file.FileName);
                var folderId = GetFolderId(path);

                SaveServerFileViewModel viewModel = new SaveServerFileViewModel()
                {
                    Id                  = Guid.NewGuid(), //TODO: update to match args id
                    ContentType         = file.ContentType,
                    CorrelationEntity   = "",             //TODO: update or remove from ServerFileViewModel and ServerFile
                    CorrelationEntityId = Guid.Empty,     //TODO: update or remove from ServerFileViewModel and ServerFile
                    File                = file,
                    HashCode            = null,
                    StorageFolderId     = folderId,
                    SizeInBytes         = file.Length,
                    StoragePath         = path,
                    StorageProvider     = "LocalFileStorage"
                };

                SaveFile(viewModel);

                filesLength += file.Length;
            }

            //add to SizeInBytes property in ServerDrive
            var serverDrive = GetDrive();

            serverDrive.StorageSizeInBytes += filesLength;
            serverDriveRepository.Update(serverDrive);
            webhookPublisher.PublishAsync("Files.DriveUpdated", serverDrive.Id.ToString(), serverDrive.Name);

            FileManagerResponse uploadResponse = operation.Upload(path, uploadFiles, action, null);

            return(uploadResponse);
        }