UNPKG

strapi-plugin-filerobot

Version:

Strapi v3 plugin for Filerobot by Scaleflex

141 lines (82 loc) 4.63 kB
# Strapi v3 plugin for Filerobot by Scaleflex ## Intro Strapi v3.x.x To know which versions of Node goes with which versions of Strapi, refer to here: https://github.com/strapi/strapi/releases If you are not familiar with using the Strapi CMS, here are some quick tutorials: Strapi v3: https://www.youtube.com/watch?v=6FnwAbd2SDY ## Install the plugin At this point, assuming that you already have an Strapi CMS installed and setup, and that you already have an super-admin user configured. It's time to install the Scaleflex Filerobot plugin for Strapi v3: `npm install strapi-plugin-filerobot` or `yarn add strapi-plugin-filerobot` ## Run `yarn build` `yarn start` ## Configure Click "Filerobot from Scaleflex" on the left vertical menu (under the plugins section) ![](https://store.filerobot.com/opendocs-global/project_test/8b86dbcad24c99df1516f2cbd9e50e0703600bdce8a83e310975d2be0d1366f8.png) - **CNAME** should be without `https://` - **Folder** can have a preceding `/` , but it's not necessary. So both `/folder_name` and `folder_name` are ok ## Usage Now you can make use of the "Check Connection", "Synchronization Status" and "Trigger Synchronization" buttons. ### Check Connection ![](https://store.filerobot.com/opendocs-global/cfe6babe5e8a3c6e746274b3bba97060d0a3313c24e1d227c2a8f7eb10b64bb2.png) ### Synchronization Status ![](https://store.filerobot.com/opendocs-global/33b8aea3920a5076aded7448cd19b7b4bccd8277554f74d3e1b94eba985c65ac.png) ### Media Tab ![](https://store.filerobot.com/opendocs-global/f40e9bdeba9d36c30f81aed9edd2497ec4d640eb86d570f7d3ab661126da9b7f.png) The **Media Tab** keeps a "log" of all your media assets. Note: when `provider` is `local`, the **Hash** is like a "unique name" generated by Strapi, and the **Alt** is like an "alternative name" generated by Strapi. Indeed, there are 2 local images that are yet to be synchronized to the Filerobot platform. ![](https://store.filerobot.com/opendocs-global/dfc9557b405f78bb40dc90ae93c5c9b230a02d3636b9691687bc80c6d44c65d2.png) And there are indeed 4 remote images on the **Filerobot platform** that are yet to be synchronized down to the Strapi CMS. ### Trigger Synchronization ![](https://store.filerobot.com/opendocs-global/c59fbab7fbd29fb2f5ad527ca9d6a95ce9a0bb9dbbba850e9a0b82f56bfe7959.png) Afterwards, the logs will be updated: ![](https://store.filerobot.com/opendocs-global/f60b44d87d4ee2eb19c8a178040c618d01df51054970d29839aae88e056ed1a8.png) Note: when `provider` is `filerobot`, the **Hash** is Filerobot's `file -> hash -> sha1`, and the **Alt** is Filerobot's `file -> uuid`. ## FMAW Tab When you **Upload**, the image will be uploaded to the Filerobot platform. Also, the same image (with Filerobot's URL) will go into the Strapi CMS: ![](https://store.filerobot.com/opendocs-global/5e7cc0fc475dfa2444231d52dc802061d35ec3f12aed5dee6d303afab96af9a2.png) If you know that `eye.jpg` only exists on the Filerobot platform (ie: haven't yet been synchronized down to the Strapi CMS), then you can check it and press "**Add to Strapi**": ![](https://store.filerobot.com/opendocs-global/d655bbbd4b8042bff15b13ec273dc5bb0ce6affd1a5d02c7be87ab325c70ea1e.png) ## REST API **Give the appropriate permissions to the authenticated user** ![](https://store.filerobot.com/opendocs-global/13baafa6622425a45822499503af540ddc37e036d5bf12b376125a662145e0bf.png) **Get the auth token** https://www.youtube.com/watch?v=TIK9CYDgs5k&list=PL2dKqfImstaROBMu304aaEfIVTGodkdHh&index=3 ``` curl --location --request POST '{domain}/auth/local' \ --form 'identifier="{an authenticated user's email}"' \ --form 'password="{an authenticated user's password'}"' ``` Potential Problem: If you get ``` error /var/www/v3/node_modules/redis/dist/index.js:42 ...options?.modules ^ SyntaxError: Unexpected token '.' ``` you need to install a lower version of Redis, eg `npm i redis@4.0.6` **Retrieve Media** GET all media ``` curl --location --request GET '{domain}/upload/files' \ --header 'Authorization: Bearer {token}' ``` GET one media ``` curl --location --request GET '{domain}/upload/files/3' \ --header 'Authorization: Bearer {token}' ``` **Retrieve custom content-type**s GET collection-type contents ``` curl --location --request GET '{domain}/tests' \ --header 'Authorization: Bearer {token}' ``` GET one collection-type content ``` curl --location --request GET '{domain}/test/1' \ --header 'Authorization: Bearer {token}' ```