Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
adonis-drive-r2
Advanced tools
Enjoy the freedom of Cloudflare R2 from your Adonisjs Application.
The Cloudflare R2 API implements the S3 API in order to enable users have a seamless migration/transition from Amazon S3 to Cloudflare R2. Because of this, this driver utilises the Amazon S3 Rest API by working within the Cloudflare S3 API compatibility instructions, which ensures S3 APIs not supported are not included in this driver.
This driver works by pointing the endpoint property required in the S3 API config to Cloudflare's R2 endpoint. See here. The Cloudflare R2 endpoint is generated within the driver by injecting the required R2 Account ID
and the name of the bucket for the active driver instance.
A major difference between this R2 driver and S3 driver is that this driver only supports bucket-level visibility. This is because Cloudflare R2 only provides bucket-level ACL and Cloudflare R2 does not support for the S3 GetObjectAcl command.
yarn add adonis-drive-r2
node ace invoke adonis-drive-r2
The configuration for R2 driver relies on certain environment variables and it is usually a good practice to validate the presence of those environment variables.
Open env.ts
file and paste the following code inside it.
R2_ACCESS_KEY_ID: Env.schema.string(),
R2_SECRET_ACCESS_KEY: Env.schema.string(),
R2_BUCKET: Env.schema.string(),
R2_ACCOUNT_ID: Env.schema.string(),
R2_PUBLIC_URL: Env.schema.string.optional(),
Update DRIVE_DISK
- DRIVE_DISK: Env.schema.enum(['local', 's3'] as const),
+ DRIVE_DISK: Env.schema.enum(['local', 's3', 'r2'] as const),
Open the config/drive.ts
and paste the following code snippet inside it.
{
disks: {
// ... other disk
r2: {
driver: 'r2',
visibility: 'private',
key: Env.get('R2_ACCESS_KEY_ID'),
secret: Env.get('R2_SECRET_ACCESS_KEY'),
bucket: Env.get('R2_BUCKET'),
accountId: Env.get('R2_ACCOUNT_ID'),
cdnUrl: Env.get('R2_PUBLIC_URL')
}
}
}
Note that the
cdnUrl
property of this R2 config (which maps to the public URl of your bucket) is required when thevisibility
of the disk ispublic
.
Open the contracts/drive.ts
file. Add the name of the new disk to the DisksList
interface
declare module '@ioc:Adonis/Core/Drive' {
interface DisksList {
// ... other disks
r2: {
config: R2DriverConfig // <-- Make sure to use the `R2DriverConfig` interface
implementation: R2DriverContract // <-- Make sure to use the `R2DriverContract` interface
}
}
}
R2
on the sidebar and open a bucket (or create one and open it).Settings
tab.Bucket Access
, click View Public Bucket URL
and copy the URL.By default, Cloudflare's bucket-level ACL, only provides read access to individual files via the public URL. The public won't be able to list your bucket items via the public URL.
To make your bucket public, click on Allow Access
within the Bucket Access
section of the Settings
tab of your bucket.
Public URLs are only useful when your bucket is public. The driver can generate signed URLs for private buckets.
A big thank you to Harminder Virk for his work of love on the AdonisJS framework and for the amazing S3 Driver for Adonisjs Drive which inspired this Driver for Cloudflare R2.
FAQs
R2 driver for AdonisJS drive
The npm package adonis-drive-r2 receives a total of 260 weekly downloads. As such, adonis-drive-r2 popularity was classified as not popular.
We found that adonis-drive-r2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.