mirror of
https://github.com/tloncorp/landscape.git
synced 2024-12-19 14:51:55 +03:00
9826f4a978
This enables using [Cloudflare R2][0] as a storage provider. Cloudflare R2 is an S3-compatible API with a generous free tier; it looks like it may cost nothing for most Urbit ships’ usage patterns. The only hitch is that R2’s endpoint is not able to be configured to be publicly readable; in order to [make a bucket public][1], you must either use an r2.dev URL, or set up your own custom URL. Caching and such is only supported on your own URL, so it sounds like that’s the case they’re encouraging people to target. This change enables R2 support by adding a configuration option to set a public URL base. If it is non-empty, it replaces the origin for any S3 upload URLs. A ship may use either its r2.dev URL or a custom URL at its discretion. As a nice side benefit, this also allows wrapping S3 access over a custom domain that you control. [0]: https://www.cloudflare.com/developer-platform/r2/ [1]: https://developers.cloudflare.com/r2/buckets/public-buckets/
63 lines
2.1 KiB
Plaintext
63 lines
2.1 KiB
Plaintext
/- *storage
|
|
|%
|
|
++ json-to-action
|
|
|= =json
|
|
^- action
|
|
=, format
|
|
|^ (parse-json json)
|
|
++ parse-json
|
|
%- of:dejs
|
|
:~ [%set-endpoint so:dejs]
|
|
[%set-access-key-id so:dejs]
|
|
[%set-secret-access-key so:dejs]
|
|
[%set-region so:dejs]
|
|
[%set-public-url-base so:dejs]
|
|
[%add-bucket so:dejs]
|
|
[%remove-bucket so:dejs]
|
|
[%set-current-bucket so:dejs]
|
|
[%set-presigned-url so:dejs]
|
|
[%toggle-service (su:dejs (perk %presigned-url %credentials ~))]
|
|
==
|
|
--
|
|
::
|
|
++ update-to-json
|
|
|= upd=update
|
|
^- json
|
|
=, format
|
|
%+ frond:enjs %storage-update
|
|
%- pairs:enjs
|
|
:~ ?- -.upd
|
|
%set-current-bucket [%'setCurrentBucket' s+bucket.upd]
|
|
%add-bucket [%'addBucket' s+bucket.upd]
|
|
%set-region [%'setRegion' s+region.upd]
|
|
%set-public-url-base [%'setPublicUrlBase' s+public-url-base.upd]
|
|
%remove-bucket [%'removeBucket' s+bucket.upd]
|
|
%set-endpoint [%'setEndpoint' s+endpoint.upd]
|
|
%set-access-key-id [%'setAccessKeyId' s+access-key-id.upd]
|
|
%set-presigned-url [%'setPresignedUrl' s+url.upd]
|
|
%toggle-service [%'toggleService' s+service.upd]
|
|
%set-secret-access-key
|
|
[%'setSecretAccessKey' s+secret-access-key.upd]
|
|
::
|
|
%credentials
|
|
:- %credentials
|
|
%- pairs:enjs
|
|
:~ [%endpoint s+endpoint.credentials.upd]
|
|
[%'accessKeyId' s+access-key-id.credentials.upd]
|
|
[%'secretAccessKey' s+secret-access-key.credentials.upd]
|
|
==
|
|
::
|
|
%configuration
|
|
:- %configuration
|
|
%- pairs:enjs
|
|
:~ [%buckets a+(turn ~(tap in buckets.configuration.upd) |=(a=@t s+a))]
|
|
[%'currentBucket' s+current-bucket.configuration.upd]
|
|
[%'region' s+region.configuration.upd]
|
|
[%'publicUrlBase' s+public-url-base.configuration.upd]
|
|
[%'service' s+service.configuration.upd]
|
|
[%'presignedUrl' s+presigned-url.configuration.upd]
|
|
==
|
|
==
|
|
==
|
|
--
|