From bcaa505ec51fc666e2d3fa81be41289c17ead11b Mon Sep 17 00:00:00 2001 From: surendrakoritalanewsignature <68114451+surendrakoritalanewsignature@users.noreply.github.com> Date: Mon, 13 Jul 2020 09:57:05 -0400 Subject: [PATCH] Commit: Perform basic file operations --- .gitignore | 7 +++++++ Controllers/AzureProviderController.cs | 17 +++++++++-------- Models/AzureFileProvider.cs | 8 ++++---- Startup.cs | 3 ++- ...Manager.AzureFileProvider.AspNet.Core.csproj | 6 +++--- 5 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de1cff2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/bin/Debug/netcoreapp2.1 +/.vs +/obj diff --git a/Controllers/AzureProviderController.cs b/Controllers/AzureProviderController.cs index ef57407..7ff3237 100644 --- a/Controllers/AzureProviderController.cs +++ b/Controllers/AzureProviderController.cs @@ -19,8 +19,9 @@ public class AzureProviderController : Controller public AzureProviderController(IHostingEnvironment hostingEnvironment) { this.operation = new AzureFileProvider(); - this.operation.RegisterAzure("<--accountName-->", "<--accountKey-->", "<--blobName-->"); - this.operation.SetBlobContainer("<--blobPath-->", "<--filePath-->"); + // Create a storage account in azure, modify storage name, key, + this.operation.RegisterAzure("samplestorageaccount10", "HDTtipcpTx44LAKfnnWon1bhFZfZVpE6Vt5ToWihBPOgPmKOPkayd+i902eCm3V2Ms1dEi2df4JuKrrdbSoXOw==", "files"); + this.operation.SetBlobContainer("https://samplestorageaccount10.blob.core.windows.net/files/", "https://samplestorageaccount10.blob.core.windows.net/files/Files"); //---------- //For example //this.operation.RegisterAzure("azure_service_account", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "files"); @@ -32,8 +33,8 @@ public object AzureFileOperations([FromBody] FileManagerDirectoryContent args) { if (args.Path != "") { - string startPath = "<--blobPath-->"; - string originalPath = ("<--filePath-->").Replace(startPath, ""); + string startPath = "https://samplestorageaccount10.blob.core.windows.net/files/"; + string originalPath = ("https://samplestorageaccount10.blob.core.windows.net/files/Files").Replace(startPath, ""); //----------------- //For example //string startPath = "https://azure_service_account.blob.core.windows.net/files/"; @@ -46,11 +47,11 @@ public object AzureFileOperations([FromBody] FileManagerDirectoryContent args) { case "read": // Reads the file(s) or folder(s) from the given path. - return Json(this.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems, args.Data))); + return 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. return this.ToCamelCase(this.operation.Delete(args.Path, args.Names, args.Data)); - case "details": + case "GetDetails": // 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": @@ -88,8 +89,8 @@ public ActionResult AzureUpload(FileManagerDirectoryContent args) { if (args.Path != "") { - string startPath = "<--blobPath-->"; - string originalPath = ("<--filePath-->").Replace(startPath, ""); + string startPath = "https://samplestorageaccount10.blob.core.windows.net/files/"; + string originalPath = ("https://samplestorageaccount10.blob.core.windows.net/files/Files").Replace(startPath, ""); args.Path = (originalPath + args.Path).Replace("//", "/"); //---------------------- //For example diff --git a/Models/AzureFileProvider.cs b/Models/AzureFileProvider.cs index 8e04d90..d841d24 100644 --- a/Models/AzureFileProvider.cs +++ b/Models/AzureFileProvider.cs @@ -8,9 +8,9 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.WindowsAzure.Storage; -using Microsoft.WindowsAzure.Storage.Auth; -using Microsoft.WindowsAzure.Storage.Blob; +using Microsoft.Azure.Storage; +using Microsoft.Azure.Storage.Auth; +using Microsoft.Azure.Storage.Blob; using Syncfusion.EJ2.FileManager.Base; @@ -483,7 +483,7 @@ protected async Task UploadAsync(IEnumerable fil existFiles.Add(fileName); } } - else if (action == "remove") + else if (action == "delete") { if (File.Exists(absoluteFilePath)) { diff --git a/Startup.cs b/Startup.cs index 2ee2dfe..cdedb98 100644 --- a/Startup.cs +++ b/Startup.cs @@ -25,7 +25,8 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + // services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddMvc(); services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => diff --git a/Syncfusion.EJ2.FileManager.AzureFileProvider.AspNet.Core.csproj b/Syncfusion.EJ2.FileManager.AzureFileProvider.AspNet.Core.csproj index d0d28fc..f1cfe42 100644 --- a/Syncfusion.EJ2.FileManager.AzureFileProvider.AspNet.Core.csproj +++ b/Syncfusion.EJ2.FileManager.AzureFileProvider.AspNet.Core.csproj @@ -24,9 +24,9 @@ - - - + + +