How are you able to upload files even 2GB? I'm not able to figure out how to do this.
How are you able to upload files even 2GB? I'm not able to figure out how to do this.
get: The specified method is not allowed against this resource (10060)




function retrieve (url, env) {
const path = url.hostname + url.pathname;
const split = path.split("/");
const tmpIndex = split.indexOf("tmp");
if (tmpIndex >= 0) {
split.splice(tmpIndex, 1);
const bucket = env.TMP_BUCKET;
const key = split.join("/");
return bucket.get(key);
} else {
const bucket = env.BIG_BUCKET;
const key = split.join("/");
return bucket.get(key);
}
}
export default {
async fetch (request, env, context) {
const cache = await caches.open("r2");
const cachedResponse = await cache.match(request);
if (cachedResponse)
return cachedResponse;
const object = await retrieve(new URL(request.url), env);
if (object === null)
return fetch(request);
const body = await object.body;
const headers = new Headers();
object.writeHttpMetadata(headers);
headers.set('etag', object.httpEtag);
headers.append('Cache-Control', 's-maxage=691200');
const response = new Response(body, { headers });
const range = request.headers.get("Range");
if (range === null) {
context.waitUntil(cache.put(request, response.clone()));
return response;
} else {
await cache.put(request, response);
return cache.match(request);
}
}
};