Skip to content

Commit

Permalink
Merge pull request #48 from sivakumars3442/master
Browse files Browse the repository at this point in the history
914579: Moved the Serialize method to model file.
  • Loading branch information
keerthanaRajendran authored Oct 10, 2024
2 parents 3b89905 + f0af449 commit f7781b6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
25 changes: 8 additions & 17 deletions Controllers/AzureProviderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,31 @@ public object AzureFileOperations([FromBody] FileManagerDirectoryContent args)
{
case "read":
// Reads the file(s) or folder(s) from the given path.
return this.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems, args.Data));
return this.operation.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));
return this.operation.ToCamelCase(this.operation.Delete(args.Path, args.Names, args.Data));
case "details":
// Gets the details of the selected file(s) or folder(s).
return this.ToCamelCase(this.operation.Details(args.Path, args.Names, args.Data));
return this.operation.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, args.Data));
return this.operation.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.
return this.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive, args.Data));
return this.operation.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive, args.Data));
case "rename":
// Renames a file or folder.
return this.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName, false, args.ShowFileExtension, args.Data));
return this.operation.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName, false, args.ShowFileExtension, args.Data));
case "copy":
// 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));
return this.operation.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.
return this.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data));
return this.operation.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data));
}
return null;
}
public string ToCamelCase(object userData)
{
JsonSerializerOptions options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};

return JsonSerializer.Serialize(userData, options);
}

// Uploads the file(s) into a specified path
[HttpPost("AzureUpload")]
Expand Down
11 changes: 11 additions & 0 deletions Models/AzureFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Syncfusion.EJ2.FileManager.Base;
using System.Text;
using Azure.Storage.Blobs.Specialized;
using System.Text.Json;

namespace Syncfusion.EJ2.FileManager.AzureFileProvider
{
Expand Down Expand Up @@ -1344,5 +1345,15 @@ protected virtual AccessPermission GetFilePermission(string path)
string fileName = Path.GetFileName(path);
return GetPermission(parentPath, fileName, true);
}

public string ToCamelCase(object userData)
{
JsonSerializerOptions options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};

return JsonSerializer.Serialize(userData, options);
}
}
}

0 comments on commit f7781b6

Please sign in to comment.