docs(adonis): file storage

This commit is contained in:
Julien Le Coupanec 2020-05-01 14:13:38 +02:00
parent 3983651d8f
commit 78a1128dff
1 changed files with 23 additions and 0 deletions

View File

@ -400,6 +400,29 @@ session.flashExcept() // Flash the request form data except the selected fields
session.withErrors() // Flash with an array of errors.
session.flash() // Flash a custom object.
/********************************************************************************************
* FILE STORAGE
* https://adonisjs.com/docs/file-system
********************************************************************************************/
const Drive = use('Drive')
Drive.exists(relativePath) // Find if a file/directory exists or not.
Drive.get(relativePath, encoding = utf-8) // Get file contents as a buffer or string.
Drive.getStream(relativePath) // Get file as a stream.
Drive.put(relativePath, content, options = {}) // Create a new file with given contents (creates any missing directories).
Drive.prepend(relativePath, content, options = {}) // Prepend content to a file (creates a new file if path doesnt exist).
Drive.append(relativePath, content, options = {}) // Append content to a file (creates a new file if path doesnt exist).
Drive.delete(relativePath) // Remove existing file.
Drive.move(src, dest, options = {}) // Move file from one directory to another.
Drive.copy(src, dest, options = {}) // Copy file from one directory to another.
// For S3 & Spaces drivers
Drive.getObject(location, params) // Get S3 object for a given file (for params info, see S3 params).
Drive.getUrl(location, [bucket]) // Get url for a given file (accepts optional alternative bucket param).
Drive.getSignedUrl(location, expiry = 900, params) // Get signed url for a given file (expiry set to 15mins by default).
/********************************************************************************************
* SOCIAL AUTHENTICATION
* https://adonisjs.com/docs/social-auth