Hello all, first off, I apologize for a potentially dumb question. I am not able to initialize an R2 object and test it out correctly. I have the R2 object code taken from the documentation, which is shown below. I am trying to call this object from a different module and execute it, but its just erroring out whatever i try. here is my latest attempt, getting errors about that I didn't initialize the object properly or that I didn't have the right formats. I appreciate anyone who can give me pointers, nothing is available on google.
//////////////////////////////////////////////////// my attempt at creating sample data in r2 ///////////////////////////////////////////////////
// r2PushData.js import r2Object from './objectR2';
// Create an instance of Env const env = { R2_BUCKET: R2Bucket, AUTH_KEY_SECRET: 'hidden-from-chat', };
// Create an instance of R2Bucket env.R2_BUCKET = new R2Bucket;
// Use the exported fetch function to push data to the R2 bucket const requestData = "Test body 'first upload of data to r2'";
r2Object.fetch(request, env, {}).then((response) => { console.log(response.status); console.log(response.statusText); }); /////////////////////////////////////// This is the object below, no errors with the file. //////////////////////////////////////
In this video , we'll show you how to integrate R2 storage into your applications using Cloudflare's Workers API and Wrangler, a command-line tool for building and deploying Cloudflare Workers. With R2's global object storage and zero egress fees, building scalable and efficient applications has never been easier!