Skip to content

Commit

Permalink
Merge pull request SyncfusionExamples#8 from Bhuvaneswarin/master
Browse files Browse the repository at this point in the history
feature(EJ2-36473) - Updated the upload customization source changes …
  • Loading branch information
gsumankumar authored Mar 20, 2020
2 parents c7d002f + 1c584ed commit f3a504b
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 193 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

### Azure Cloud File System Provider

#### New Features

- `#262023` - Support has been provided for upload customization.

## 17.4.43 (2020-01-14)

### Azure Cloud File System Provider
Expand Down
49 changes: 27 additions & 22 deletions Controllers/AzureProviderController.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using Syncfusion.EJ2.FileManager.AzureFileProvider;
using System;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Collections.Generic;
using Syncfusion.EJ2.FileManager.Base;
using System;
using Syncfusion.EJ2.FileManager.AzureFileProvider;

namespace EJ2AzureASPCoreFileProvider.Controllers
{

[Route("api/[controller]")]
[EnableCors("AllowAllOrigins")]
public class AzureProviderController : Controller
Expand All @@ -23,7 +22,7 @@ public AzureProviderController(IHostingEnvironment hostingEnvironment)
this.operation.RegisterAzure("<--accountName-->", "<--accountKey-->", "<--blobName-->");
this.operation.SetBlobContainer("<--blobPath-->", "<--filePath-->");
//----------
//for example
//For example
//this.operation.RegisterAzure("azure_service_account", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "files");
//this.operation.setBlobContainer("https://azure_service_account.blob.core.windows.net/files/", "https://azure_service_account.blob.core.windows.net/files/Files");
//---------
Expand All @@ -36,7 +35,7 @@ public object AzureFileOperations([FromBody] FileManagerDirectoryContent args)
string startPath = "<--blobPath-->";
string originalPath = ("<--filePath-->").Replace(startPath, "");
//-----------------
// for example
//For example
//string startPath = "https://azure_service_account.blob.core.windows.net/files/";
//string originalPath = ("https://azure_service_account.blob.core.windows.net/files/Files").Replace(startPath, "");
//-------------------
Expand All @@ -46,30 +45,29 @@ public object AzureFileOperations([FromBody] FileManagerDirectoryContent args)
switch (args.Action)
{
case "read":
// reads the file(s) or folder(s) from the given path.
return Json(this.ToCamelCase(this.operation.GetFiles(args.Path, args.Data)));
// Reads the file(s) or folder(s) from the given path.
return Json(this.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems, args.Data)));
case "delete":
// deletes the selected file(s) or folder(s) from the given path.
// Deletes the selected file(s) or folder(s) from the given path.
return this.ToCamelCase(this.operation.Delete(args.Path, args.Names, args.Data));
case "details":
// gets the details of the selected file(s) or folder(s).
// Gets the details of the selected file(s) or folder(s).
return this.ToCamelCase(this.operation.Details(args.Path, args.Names, args.Data));
case "create":
// creates a new folder in a given path.
return this.ToCamelCase(this.operation.Create(args.Path, args.Name));
// Creates a new folder in a given path.
return this.ToCamelCase(this.operation.Create(args.Path, args.Name, args.Data));
case "search":
// gets the list of file(s) or folder(s) from a given path based on the searched key string.
// Gets the list of file(s) or folder(s) from a given path based on the searched key string.
return this.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive, args.Data));
case "rename":
// renames a file or folder.
// Renames a file or folder.
return this.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName, false, args.Data));
case "copy":
// copies the selected file(s) or folder(s) from a path and then pastes them into a given target path.
// Copies the selected file(s) or folder(s) from a path and then pastes them into a given target path.
return this.ToCamelCase(this.operation.Copy(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data));
case "move":
// cuts the selected file(s) or folder(s) from a path and then pastes them into a given target path.
// Cuts the selected file(s) or folder(s) from a path and then pastes them into a given target path.
return this.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data));

}
return null;
}
Expand All @@ -84,7 +82,7 @@ public string ToCamelCase(object userData)
});
}

// uploads the file(s) into a specified path
// Uploads the file(s) into a specified path
[Route("AzureUpload")]
public ActionResult AzureUpload(FileManagerDirectoryContent args)
{
Expand All @@ -94,25 +92,32 @@ public ActionResult AzureUpload(FileManagerDirectoryContent args)
string originalPath = ("<--filePath-->").Replace(startPath, "");
args.Path = (originalPath + args.Path).Replace("//", "/");
//----------------------
//for example
//For example
//string startPath = "https://azure_service_account.blob.core.windows.net/files/";
//string originalPath = ("https://azure_service_account.blob.core.windows.net/files/Files").Replace(startPath, "");
//args.Path = (originalPath + args.Path).Replace("//", "/");
//----------------------
}
operation.Upload(args.Path, args.UploadFiles, args.Action, args.Data);
FileManagerResponse uploadResponse = operation.Upload(args.Path, args.UploadFiles, args.Action, args.Data);
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 Json("");
}

// downloads the selected file(s) and folder(s)
// Downloads the selected file(s) and folder(s)
[Route("AzureDownload")]
public object AzureDownload(string downloadInput)
{
FileManagerDirectoryContent args = JsonConvert.DeserializeObject<FileManagerDirectoryContent>(downloadInput);
return operation.Download(args.Path, args.Names, args.Data);
}

// gets the image(s) from the given path
// Gets the image(s) from the given path
[Route("AzureGetImage")]
public IActionResult AzureGetImage(FileManagerDirectoryContent args)
{
Expand Down
Loading

0 comments on commit f3a504b

Please sign in to comment.