drive.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * Config source: https://git.io/JBt3o
  3. *
  4. * Feel free to let us know via PR, if you find something broken in this config
  5. * file.
  6. */
  7. import Env from '@ioc:Adonis/Core/Env'
  8. import { driveConfig } from '@adonisjs/core/build/config'
  9. import Application from '@ioc:Adonis/Core/Application'
  10. /*
  11. |--------------------------------------------------------------------------
  12. | Drive Config
  13. |--------------------------------------------------------------------------
  14. |
  15. | The `DriveConfig` relies on the `DisksList` interface which is
  16. | defined inside the `contracts` directory.
  17. |
  18. */
  19. export default driveConfig({
  20. /*
  21. |--------------------------------------------------------------------------
  22. | Default disk
  23. |--------------------------------------------------------------------------
  24. |
  25. | The default disk to use for managing file uploads. The value is driven by
  26. | the `DRIVE_DISK` environment variable.
  27. |
  28. */
  29. disk: Env.get('DRIVE_DISK'),
  30. disks: {
  31. /*
  32. |--------------------------------------------------------------------------
  33. | Local
  34. |--------------------------------------------------------------------------
  35. |
  36. | Uses the local file system to manage files. Make sure to turn off serving
  37. | files when not using this disk.
  38. |
  39. */
  40. local: {
  41. driver: 'local',
  42. visibility: 'public',
  43. /*
  44. |--------------------------------------------------------------------------
  45. | Storage root - Local driver only
  46. |--------------------------------------------------------------------------
  47. |
  48. | Define an absolute path to the storage directory from where to read the
  49. | files.
  50. |
  51. */
  52. root: Application.tmpPath('uploads'),
  53. /*
  54. |--------------------------------------------------------------------------
  55. | Serve files - Local driver only
  56. |--------------------------------------------------------------------------
  57. |
  58. | When this is set to true, AdonisJS will configure a files server to serve
  59. | files from the disk root. This is done to mimic the behavior of cloud
  60. | storage services that has inbuilt capabilities to serve files.
  61. |
  62. */
  63. serveFiles: true,
  64. /*
  65. |--------------------------------------------------------------------------
  66. | Base path - Local driver only
  67. |--------------------------------------------------------------------------
  68. |
  69. | Base path is always required when "serveFiles = true". Also make sure
  70. | the `basePath` is unique across all the disks using "local" driver and
  71. | you are not registering routes with this prefix.
  72. |
  73. */
  74. basePath: '/uploads'
  75. },
  76. /*
  77. |--------------------------------------------------------------------------
  78. | S3 Driver
  79. |--------------------------------------------------------------------------
  80. |
  81. | Uses the S3 cloud storage to manage files. Make sure to install the s3
  82. | drive separately when using it.
  83. |
  84. |**************************************************************************
  85. | npm i @adonisjs/drive-s3
  86. |**************************************************************************
  87. |
  88. */
  89. s3: {
  90. driver: 's3',
  91. visibility: 'private',
  92. key: Env.get('S3_KEY'),
  93. secret: Env.get('S3_SECRET'),
  94. region: Env.get('S3_REGION'),
  95. bucket: Env.get('S3_BUCKET'),
  96. endpoint: Env.get('S3_ENDPOINT')
  97. // For minio to work
  98. // forcePathStyle: true,
  99. }
  100. /*
  101. |--------------------------------------------------------------------------
  102. | GCS Driver
  103. |--------------------------------------------------------------------------
  104. |
  105. | Uses the Google cloud storage to manage files. Make sure to install the GCS
  106. | drive separately when using it.
  107. |
  108. |**************************************************************************
  109. | npm i @adonisjs/drive-gcs
  110. |**************************************************************************
  111. |
  112. */
  113. // gcs: {
  114. // driver: 'gcs',
  115. // visibility: 'public',
  116. // keyFilename: Env.get('GCS_KEY_FILENAME'),
  117. // bucket: Env.get('GCS_BUCKET'),
  118. /*
  119. |--------------------------------------------------------------------------
  120. | Uniform ACL - Google cloud storage only
  121. |--------------------------------------------------------------------------
  122. |
  123. | When using the Uniform ACL on the bucket, the "visibility" option is
  124. | ignored. Since, the files ACL is managed by the google bucket policies
  125. | directly.
  126. |
  127. |**************************************************************************
  128. | Learn more: https://cloud.google.com/storage/docs/uniform-bucket-level-access
  129. |**************************************************************************
  130. |
  131. | The following option just informs drive whether your bucket is using uniform
  132. | ACL or not. The actual setting needs to be toggled within the Google cloud
  133. | console.
  134. |
  135. */
  136. // usingUniformAcl: false,
  137. // },
  138. }
  139. })