Waiiki
03/31/2023, 9:26 PMWaiiki
03/31/2023, 9:27 PMuploadImageToR2: builder.mutation<any, cloudFlareUploadRequest>({
query: (uploadRequest) => ({
url: `${uploadRequest.preSignedUrl}`,
method: "PUT",
body: uploadRequest.file,
headers: {
"Origin": "http://localhost:3001",
"Content-Type": uploadRequest.file.type
},
}),
transformResponse: (response: any, meta) => {
console.log("Success");
return response;
},
transformErrorResponse: (response, meta, arg) => {
return {
originalArg: arg,
error: response,
};
},
}),
This seems correct to mekian
03/31/2023, 9:39 PMContent-Type
as an allowed headerWaiiki
03/31/2023, 9:43 PMWaiiki
03/31/2023, 9:43 PMaccess to fetch at ... from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Waiiki
03/31/2023, 9:44 PMkian
03/31/2023, 9:45 PMaccountid.r2.cloudflarestorage.com/bucketname/
Waiiki
03/31/2023, 9:45 PMWaiiki
03/31/2023, 9:46 PMkian
03/31/2023, 9:49 PMWaiiki
03/31/2023, 10:12 PMvar credentials = new BasicAWSCredentials("accesskey",
"secretkey");
_s3Client = new AmazonS3Client(credentials, new AmazonS3Config
{
ServiceURL = $"https://accountid.r2.cloudflarestorage.com",
});
Waiiki
03/31/2023, 10:12 PMpublic string GetPreSignedUrl(string bucketName, string keyName)
{
AWSConfigsS3.UseSignatureVersion4 = true;
var request = new GetPreSignedUrlRequest
{
BucketName = "test-bucket",
Key = keyName,
Verb = HttpVerb.PUT,
Expires = DateTime.Now.AddMinutes(45),
};
var url = _s3Client.GetPreSignedURL(request);
return url;
}
Waiiki
03/31/2023, 10:12 PMWaiiki
03/31/2023, 10:13 PMgautam32
03/31/2023, 11:47 PMKarew
04/01/2023, 12:57 AMKarew
04/01/2023, 5:12 AMKarew
04/01/2023, 5:12 AMVitamin Protein
04/01/2023, 8:08 AMbuckett
04/01/2023, 9:17 AMR2ListOptions
to accept an include
value of expiry
which then returned the expected expiry for each item in the response.Leo_C
04/01/2023, 9:51 AMLeo_C
04/01/2023, 9:51 AMelithrar
04/01/2023, 12:50 PMLeo_C
04/01/2023, 12:58 PMelithrar
04/01/2023, 1:20 PMelithrar
04/01/2023, 1:21 PMLeo_C
04/01/2023, 3:37 PMCrazy Rabbit
04/01/2023, 5:04 PMCrazy Rabbit
04/01/2023, 5:22 PMsetCacheR2
function will also append Content-Type
header and return it in getCacheR2
function.Crazy Rabbit
04/01/2023, 5:23 PM