How to Synchronize Amazon S3 Storage Files with Essential JS 2 File Manager | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (173).NET Core  (29).NET MAUI  (203)Angular  (107)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (211)BoldSign  (13)DocIO  (24)Essential JS 2  (106)Essential Studio  (200)File Formats  (65)Flutter  (132)JavaScript  (219)Microsoft  (118)PDF  (81)Python  (1)React  (98)Streamlit  (1)Succinctly series  (131)Syncfusion  (897)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (50)Windows Forms  (61)WinUI  (68)WPF  (157)Xamarin  (161)XlsIO  (35)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (146)Chart  (127)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (618)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (39)Extensions  (22)File Manager  (6)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (501)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (42)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (381)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (17)Web  (582)What's new  (323)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Synchronize Amazon S3 Storage Files with Essential JS 2 File Manager

How to Synchronize Amazon S3 Storage Files with Essential JS 2 File Manager

Having an important file on a machine and limiting its sharing scope within an organization is no longer adequate for many corporate offices. As organizations expand around the world, people nowadays prefer to share and access such documents globally from anywhere. Amazon S3 (Simple Storage Service) provides a preferable public cloud storage resource for storing any data files in the cloud, like videos, images, documents, and more.

In this blog, I’ll walk you through how to synchronize the files and folders present in an Amazon S3 bucket with our Essential JS 2 File Manager component. The Essential JS 2 File Manager is a UI component built by Syncfusion that allows you to view and interact with a hierarchical collection of files and folders. Using this component, you can easily manage the file system and perform most common file and folder operations like read, write, delete, create, rename, upload, edit, select, and sort. It is also available on all major web platforms, including Angular, React, Vue, JavaScript, ASP.NET MVC, ASP.NET Core, and Blazor.

Moreover, you can easily cross-verify whether the files and folders displayed in the File Manager component are identical to those present in the Amazon S3 storage bucket. Let’s start with what Amazon S3 is first and then I’ll proceed with the steps to synchronize it with the Essential JS 2 File Manager.

What is Amazon S3?

Amazon S3 (Simple Storage Service) is a simple web storage services interface that you can use to store and retrieve any amount of data at any time from anywhere on the web. It provides highly scalable, reliable, fast, and inexpensive data storage infrastructure.

Creation of an Amazon S3 Bucket

Step 1: To create a new S3 bucket, sign in to the AWS (Amazon Web Services) management console and open the Amazon S3 console. Now, select the S3 service from the storage options.

AWS S3 Console Storage Options
AWS S3 Console Storage Options

Step 2: Click Create bucket to start creating an AWS S3 bucket.

Create AWS S3 Bucket
Create AWS S3 Bucket

Step 3: Provide a unique bucket name and select the region where the bucket should exist. After providing these details, click the Create button. You have now successfully created an S3 bucket using Amazon Web Services.

Step 4: Now, upload files to the bucket. To upload a file, first select your bucket and then click the Upload button.

Uploading Files to an S3 Bucket
Uploading Files to an S3 Bucket

Step 5: Set your bucket as public by right-clicking on the created bucket and then choosing the Make public option.

Making a Bucket Public
Making a Bucket Public

Now your new bucket is ready to use, so let’s see how to transfer the data from Amazon S3 storage to the Essential JS 2 File Manager component. In the next step we will create an intermediate ASP.NET Core project which acts as a service provider that will connect with the File Manager component.

Creating an Amazon S3 File Provider Project

The ASP.NET Core Amazon S3 file provider project acts as a gateway to synchronize the content between the File Manager component and Amazon S3 bucket storage. The files will flow as follows:

Amazon S3 Storage > Amazon File Provider > Essential JS 2 File Manager component

GitHub Example

You can download the Amazon S3 file provider source project from the following GitHub location:

https://github.com/SyncfusionExamples/ej2-amazon-s3-aspcore-file-provider.

An important step in this Amazon S3 file provider ASP.NETCore project is to ensure that you have registered your Amazon S3 client account details like awsAccessKeyId, awsSecretAccessKey, bucketRegion, and bucketName using the RegisterAmazonS3 method to perform the file operations.

void RegisterAmazonS3(string bucketName, string awsAccessKeyId, string awsSecretAccessKey, string bucketRegion);

Run the application

  1. Open a command prompt, clone this ready-to-use project from GitHub, and then navigate to the path where it has been placed in your system by running the following commands in order.
    git clone https://github.com/ej2-amazon-s3-aspcore-file-provider   
    
    cd ej2-amazon-s3-aspcore-file-provider
    
  2. Now, restore the NuGet packages by running the following command from the root folder.
    dotnet restore
    
  3. Build the application using the following command.
    dotnet build
    
  4. After a successful compilation, run the following command to run this file provider application.
    dotnet run
    

Now, the project will be hosted. To ensure that Amazon-s3-service works, type the following URL in your browser.

http://localhost:<port-number>/api/test

Note: Make sure to map the proper in the above URL.

Configuring File Provider Service in Essential JS 2 File Manager

Now the service project is ready to use, so next I’ll create a basic JavaScript File Manager example by referring to the getting started documentation. You can also get a runnable and pre-configured example from this GitHub repository.

To perform the basic file actions such as read, delete, copy, move, rename, and search, and to retrieve the details of files from the Amazon S3 service, start mapping the following service URLs to the ajaxSettings property of File Manager.

Note: The hostUrl will be the locally hosted port number of the S3 file provider project that was created in the previous step.

var hostUrl = http://localhost:<Port Number>/;
  ajaxSettings: {
        url: hostUrl + 'api/AmazonS3Provider/AmazonS3FileOperations'
  }

Perform download operation

To enable and perform download operations on the files, initialize the downloadUrl property within the ajaxSettings of the File Manager component.

  var hostUrl = http://localhost:<Port Number>/;
  ajaxSettings: {
        url: hostUrl + ‘api/AmazonS3Provider/AmazonS3FileOperations’,
        downloadUrl: hostUrl + ‘api/AmazonS3Provider/AmazonS3Download’
  }

Perform upload operation

To perform the upload operation in the File Manager, initialize the uploadUrl property within the ajaxSettings of the File Manager component as shown in the following sample.

  var hostUrl = http://localhost:<Port Number>/;
  ajaxSettings: {
        url: hostUrl + 'api/AmazonS3Provider/AmazonS3FileOperations',
        uploadUrl: hostUrl + 'api/AmazonS3Provider/AmazonS3Upload'
  }
File uploaded to File Manager and synchronized with S3 bucket.
File uploaded to File Manager and synchronized with S3 bucket.

Image preview settings

To enable the image preview settings in the File Manager component, initialize the getImageUrl property within the ajaxSettings property as shown in the following code.

  var hostUrl = http://localhost:<Port Number>/;
  ajaxSettings: {
        url: hostUrl + 'api/AmazonS3Provider/AmazonS3FileOperations',
         getImageUrl: hostUrl + 'api/AmazonS3Provider/AmazonS3GetImage'
  }
Image preview Essential JS 2 File Manager
Image preview in Essential JS 2 File Manager

Now, the Essential JS 2 File Manager will be rendered with the same files and folders as in the Amazon S3 bucket object as shown in the following screenshot.

File Manager Component Synchronized with an S3 Bucket
File Manager Component Synchronized with an S3 Bucket

Conclusion

To summarize, the ability to synchronize and share files and folders between an Amazon S3 bucket and the Syncfusion File Manager component allows you to have global access to local files and folders. If we make any changes to the files and folders present in the Amazon S3 cloud bucket, those changes will be reflected immediately in the File Manager component and vice versa. In just a few steps, you can create and deploy an application that uses the Essential JS 2 File Manager and connects to Amazon S3 bucket storage in a simpler way.

Try this out with our 2019 Volume 3 release and share your feedback as comments on this blog. If you need support for specific features in this component or have any questions, contact us through our support forumDirect Trac, or feedback portal. We are waiting to hear what you think about this feature!

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed