I need help with Unity C# + pages + Database
I am using unity 6 to make a website, I have successfully deployed my build in the cloud flare pages!
I am using my Google drive as my database.
(To maintain a small build size, my website is like an empty shell, so basically no text and images)
So I have stored all my text in just one .txt file including the links of the Images (all data with image urls). this .txt file is stored in my google drive.
I want my website to be able to download this text file, read it and batch download these images I need. and Everything works smooth and flawlessly in Unity.
My problems is that cloud flare pages are not allowing me to download anything from my google drive.
and I get this error
My error is Access to fetch at 'LINK_TO_MY_DRIVE_TXT_FILE' from origin 'LINK_OF_MY_DEPLOYED_BUILD_PAGES' has been blocked by CORS policy: 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.
I am looking for a solution to use the free cloudflare database to be able to store my text file and all the images within this database. so that I can access these data from my cloudflare pages.
1. I need information regarding how to store my text file data in the database, also I don;t know how to use these sql rows/colums with key and values.
2. I want understand how can I access this txt file. is unity webrequest feature will be enough for this purpose? as I am using the async/await related functions to handle my text and image downloading.
2 Replies
🥲 looks like no one can help me here
Hey, I am not a unity developer but I can try answering your questions.
You might want to find a solution for CORS, it is a bit tricky to work with it. I am not sure if Google Drive allows you to set a URL that can access the files.
To store the data in any of the database products from Cloudflare, you need to check what kind of data you are have, is it key-value, tabular, etc. Based on that you can select the appropriate service.
If you want to store and access the txt files, you can use R2 to upload the whole file. We already have documentation on how to use any of these services