Skip to content

Commit

Permalink
Commit: Perform basic file operations
Browse files Browse the repository at this point in the history
  • Loading branch information
surendrakoritalanewsignature committed Jul 13, 2020
1 parent 321e4c9 commit bcaa505
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/bin/Debug/netcoreapp2.1
/.vs
/obj
17 changes: 9 additions & 8 deletions Controllers/AzureProviderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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/";
Expand All @@ -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":
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Models/AzureFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -483,7 +483,7 @@ protected async Task<FileManagerResponse> UploadAsync(IEnumerable<IFormFile> fil
existFiles.Add(fileName);
}
}
else if (action == "remove")
else if (action == "delete")
{
if (File.Exists(absoluteFilePath))
{
Expand Down
3 changes: 2 additions & 1 deletion Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.7" />
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="18.2.0.44" />
</ItemGroup>

</Project>

0 comments on commit bcaa505

Please sign in to comment.