kotx / render Goto Github PK
View Code? Open in Web Editor NEWCloudflare Worker to proxy and cache requests to R2
License: MIT License
Cloudflare Worker to proxy and cache requests to R2
License: MIT License
Hey!
In src/index.ts
, it is said that the R2 API requires etag to not be quoted. I don't find this information in the API documentation. Moreover, with Miniflare, etag should be left quoted, otherwise, there is no match.
It will always display that the file cannot be found, and the deployment of GitHub Action has been completed. After opening the Workers page, it will display File Not Found
The possible reason is that the Chinese characters encoded in UTF-8 were read in GBK format.
An example:
搴斿鐗规畩鏃舵湡鐨勫簲鎬ョ墿璧勬竻鍗晇1.2.pdf
Actually should be:
应对特殊时期的应急物资清单v1.2.pdf
hy there can u help me I'm new in this stuff I don't understand how to upload file larger then 300mb I checked the guide but If try to upload with guide then I have to change code every single time I upload file in r2 through Wrangler CLI if u have any suggestion to to upload file larger then 300mb then please let mr know..
Hi,
thanks for sharing this great tool.
I've a question:
is there a specific reason for having cache.put fired also when the response is already in cache (previous cache.match)?
Thanks!
I'm very new at this and having a bad time
The wrangler.toml does not have a "type" entry so "wrangler publish" fails like this:
$ wrangler r2 bucket list
Error: missing field `type`
I tried putting type = "javascript"
in the file but it did not work
$ wrangler publish
✨ Basic JavaScript project found. Skipping unnecessary build!
Error: The entrypoint of your Worker (dist/index.js) could not be found.
I tried type = "typescript"
but also did not work
$ wrangler publish
Error: enum TargetType does not have variant constructor typescript
I tried some other random guesses but nothing that worked
A handy feature would be the ability to list objects. I was thinking maybe if on a get request a file isn't found, try list objects with the the path as the prefix.
I can do a PR if you think this is a good idea.
Whenever I try playing music on my website, I get either Failed to load resource: net::ERR_CACHE_OPERATION_NOT_SUPPORTED
or CORS error like
.
Googling returned 0 results, what can I do? I've been fighting with CORS since I thought that's the issue, but this made me think CORS might not be the issue. could it be the worker?
inside the wrangler.toml
file, I set my origins to:
ALLOWED_ORIGINS = "https://djkato.net/"
All other files load just fine(eg videos, images). Just audio seems messed up, regardless if crossorigin="anonymous"
is set via html property on the audio element, or before initializing the web Audio API context through HTMLMediaElement.crossOrigin = "anonymous"
, or even not set anywhere. if I don't set it anywhere, I get "audio source set to none due to cors issues" or something along those lines.
Any tips on solving this? Thanks!
the <html>
without a language specified causes a WC3 validation warning
this should probably default to English (<html lang="en">
) since the UI elements are in English, however, a person might want to change it if their filenames are in another language
could this potentially be added as a variable in wrangler.toml
Please consider adding support for Edge-Side-Includes
Hey there, this is a super well done library. Thank you!
I'm not sure if I'm missing something in your documentation or if it's just not possible, but how can I invalidate a url when the object at a R2 path changes? For example, when I'm updating the contents of my static website.
maybe this is a Cloudflare issue or something but I'll mention it here
you can definitely create 0-byte files in R2 buckets
but trying to access them through your script results in odd behavior
using a HEAD request it returns a HTTP 204 (No Content) which is sensible
however using a GET request, the browser gets a HTTP 500 (Internal Server Error) along with some HTML claiming there was an error 1101
if I test it in the worker dashboard this is what I see:
If an object in R2 is deleted then the cache still serves the old file. Even if I upload a new file at the same path then the old file is still served.
I suggest a way to either (a) opt-out of the cache completely, or (b) provide some way to manually invalidate the cache. Any ideas? Particularly ideas for (b)?
R2 API can process range requests now, it seems. We can remove the range-parser
dependency and directly pass the header instead.
Hi, just noticed that you are checking for response.ok() to see if cache was hit. This will fail if cache returned a 304 response to a correct etag.
I would like to know how I could apply an Access-Control-Allow-Origin to a certain domain from R2, could it be done with this worker? Currently the content of my bucket is not shown because of this.
I installed the code in a worker so that I could display mainly images, unfortunately the script always presents errors in the first requests of some files, after a few attempts the photo is displayed to the user
after I reload the page a few times:
after I reload the page a few times, the first image is displayed but the others keep showing error:
the workers panel:
this error seems to be occasional, there are photos that load without problems, others that don't load on the first try and some load only after I reload the pages many times, at first I thought it could be a problem with Cloudflare R2 but I didn't find any problem in the status page.
In the case where I have around 17,000 files in a directory, only the first 600-900 are shown in the directory listing.
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.