SkillAgentSearch skills...

Filehub

The FileHub is a service that standardizes file management, independent of the storage platform used. Moreover, it makes file persistence easier when we think about multiple storage places, serving as requests gateway, using a safe and easy way.

Install / Use

/learn @paulophgf/Filehub
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<div align="center"> <img src="https://user-images.githubusercontent.com/32067860/205514546-468d61e5-28a4-4e6f-a172-857330620b79.png" alt="drawing" width="200"/>

REST API Java Version Spring Boot Version License

</div>

Read this in other languages: English, Portuguese

The FileHub is a service that standardizes file management, independent of the storage platform used. Moreover, it makes file persistence easier when we think about multiple storage places, serving as requests gateway, using a safe and easy way.

Sections

<!--------------------------------------------------------------------------------------------------------------------->

Configuration

         The FileHub uses an XML configuration file where the properties and some rules are defined. That file can be created locally where the service is executed or remotely using a Git repository. The following table shows the environment variables used to define where the configuration file is:

<table> <tbody> <tr> <td colspan="2" style="text-align: left"> * <sub>Required</sub> </td> </tr> <tr style="background-color: #DAE8FC; color: black"> <th>Variable name</th> <th>Description</th> </tr> <tr style="background-color: white; color: black"> <td>CONFIG_TYPE <i style="color: red">*</i></td> <td>Define if the file is locally or remotely.<br> Default value: <b>LOCAL_FILE</b><br> Possible values:<br> <li>LOCAL_FILE</li> <li>GIT_FILE</li> </td> </tr> <tr style="background-color: white; color: black"> <td>LOCAL_FILE_PATH</td> <td>Used when the configuration file is local. It shows where the configuration file is in the Operational System.<br>Example: C:/filehub/example.xml</td> </tr> <tr style="background-color: white; color: black"> <td>CONFIG_GIT_FILE_PATH</td> <td> Git repository file address (File URL)<br> Use <b>raw</b> file URL (plain text) </td> </tr> <tr style="background-color: white; color: black"> <td>CONFIG_GIT_FILE_TOKEN</td> <td>Git repository authentication token</td> </tr> <tr style="background-color: white; color: black"> <td>MAX_FILE_SIZE</td> <td>Maximum file size allowed.<br>Default value: <b>7000000000</b></td> </tr> <tr style="background-color: white; color: black"> <td>MAX_REQUEST_SIZE</td> <td>Maximum request size allowed<br>Default value: <b>7000000000</b></td> </tr> </tbody> </table> <!--------------------------------------------------------------------------------------------------------------------->

Concepts

         Before executing the service it is necessary to define which storage platforms will be used, in addition to configuring the access parameters of each one independently. To do that the FileHub uses an XML file that will be read when the service starts. The file contains some elements that will process the requests. Each element will be explained next:

<!--------------------------------------------------------------------------------------------------------------------->

Storage

         It is used to represent a storage platform. A storage has an ID to identify it inside the service and a type. Each type corresponds to a service or a storage platform, for example, a FTP server, a cloud service like the AWS S3 or a local directory where the FileHub is running. In other words, each type has their own properties for access and specifications.

         In the configuration file the storages are defined inside of tag storages like shown in the example below:

<filehub>
   <storages>
       <storage id="S3-Test" type="AWS_S3">
           <region>us-east-2</region>
           <secretKeyId>G5HG4G66RDYIYE1</secretKeyId>
           <secretKey>6F51E6f1e6F7A2E4F761F61fd51s1F</secretKey>
           <bucket>test</bucket>
       </storage>
       <storage id="FileSystem-Test" type="FILE_SYSTEM">
           <baseDir>C:\Users\user\filehub</baseDir>
       </storage>
   </storages>
</filehub>
<p align="center"><sub>Storage declaration example</sub></p> <br>

         All storage elements have an ID and a type. The ID will identify the storage and the type will define which configuration properties the storage has. The storage types are listed next:

<!---------------------------------------------------------------------------------------------------------------------> <table> <tbody> <tr style="background-color: white; color: black"> <th colspan="1" style="text-align: center"> <img src="https://user-images.githubusercontent.com/32067860/205519206-bf7fe5be-d8d6-4853-8119-d61c7c11a8f8.png" alt="drawing" width="80"/> <div>Local File System</div> </th> <td colspan="1"> <div>It defines as storage a server directory where the FileHub is running.</div> <div><b>Type:</b> FILE_SYSTEM</div> </td> </tr> <tr style="background-color: white; color: black"> <td colspan="2"> <div style="color: blue"><b>Properties:</b></div> <li><b>baseDir:</b> root directory</li> </td> </tr> <!--######################################################################################--> <tr style="background-color: transparent; border-width: 0px;"><td colspan="2"></td></tr> <tr style="background-color: white; color: black"> <th colspan="1" style="text-align: center"> <img src="https://user-images.githubusercontent.com/32067860/205519209-92f81d0b-b38a-416b-923e-cb2d2cab8ee4.png" alt="drawing" width="80"/> <div>Amazon S3</div> </th> <td colspan="1"> <div>It defines a S3 bucket as a storage.</div> <div><b>Type:</b> AWS_S3</div> </td> </tr> <tr style="background-color: white; color: black"> <td colspan="2"> <div style="color: blue"><b>Properties:</b></div> <li><b>region:</b> AWS region (e.g.: sa-east-1)</li> <li><b>secretKeyId:</b> IAM user ID</li> <li><b>secretKey:</b> IAM user secret</li> <li><b>bucket:</b> S3 bucket name</li> <li><b>baseDir:</b> root directory</li> </td> </tr> <!--######################################################################################--> <tr style="background-color: transparent; border-width: 0px;"><td colspan="2"></td></tr> <tr style="background-color: white; color: black"> <th colspan="1" style="text-align: center"> <img src="https://user-images.githubusercontent.com/32067860/209043609-a6bacd02-19b8-4b01-9887-98a0f96ca1c1.png" alt="drawing" width="80"/> <div>Google Cloud Storage</div> </th> <td colspan="1"> <div>It creates a link with a google cloud storage bucket</div> <div><b>Type:</b> GOOGLE_CLOUD</div> </td> </tr> <tr style="background-color: white; color: black"> <td colspan="2"> <div style="color: blue"><b>Properties:</b></div> <li> <b>jsonCredentials:</b> JSON object generated by account service <br/>(APIs & Services > Credentials > Service Accounts > Keys) <br/>Download the key, copy the JSON object and paste inside the jsonCredentials tag </li> <li><b>bucket:</b> storage bucket name</li> <li><b>baseDir:</b> root directory</li> </td> </tr> <!--######################################################################################--> <tr style="background-color: transparent; border-width: 0px;"><td colspan="2"></td></tr> <tr style="background-color: white; color: black"> <th colspan="1" style="text-align: center"> <img src="https://user-images.githubusercontent.com/32067860/207856945-47f8929e-8292-42fe-91d4-0a6495c264e0.png" alt="drawing" width="80"/> <div>Dropbox</div> </th> <td colspan="1"> <div>It creates a link with a dropbox account</div> <div><b>Type:</b> DROPBOX</div> <div><b>Limitations:</b> <li><b>Access Token:</b> The refresh token operation was not implemented. It is necessary to generate a new token when you use this kind of storage</li> <li><b>File Size:</b> The maximum file size is 150 Mb. Operations with big files will not work.</li> </div> </td> </tr> <tr style="background-color: white; color: black"> <td colspan="2"> <div style="color: blue"><b>Properties:</b></div> <li><b>accessToken
View on GitHub
GitHub Stars14
CategoryDevelopment
Updated1y ago
Forks2

Languages

Java

Security Score

80/100

Audited on Mar 14, 2025

No findings