xKAF Mirror
GUIDEAbout 10 minutes, no codingপ্রায় ১০ মিনিট, কোনো কোডিং নেই

Set up your own Drive mirror

নিজের Drive মিরর সেটআপ করুন

Follow these steps in order. You will create a free Google key, build your worker.js on this site, and put it online with Cloudflare Workers.

ধাপগুলো ক্রমানুসারে করুন। একটি ফ্রি Google key বানাবেন, এই সাইটে worker.js তৈরি করবেন, আর Cloudflare Workers দিয়ে অনলাইনে চালু করবেন।

Before you startশুরুর আগে

You only need two free accounts:

শুধু দুটি ফ্রি অ্যাকাউন্ট লাগবে:

GoogleThe account that owns the files you want to share.যে অ্যাকাউন্টে শেয়ার করার ফাইলগুলো আছে।
CloudflareFree plan at dash.cloudflare.com.dash.cloudflare.com-এ ফ্রি প্ল্যান।
10 minutes১০ মিনিটA computer is easiest, but a phone works too.কম্পিউটারে সহজ, তবে ফোনেও করা যায়।

Your data stays yours. The generator runs only in your browser. Your Google secret and token go straight to Google, never to xKAF.

আপনার তথ্য আপনারই থাকে। জেনারেটর শুধু আপনার ব্রাউজারে চলে। Google secret ও token সরাসরি Google-এ যায়, কখনো xKAF-এ না।

1Create a Google Cloud projectGoogle Cloud project তৈরি করুন

  1. Open console.cloud.google.com/projectcreate.
  2. Type any name (for example my-mirror) and click Create.
  3. Make sure the new project is selected at the top, then open the Google Drive API page and click Enable.
  1. console.cloud.google.com/projectcreate খুলুন।
  2. যেকোনো নাম দিন (যেমন my-mirror), তারপর Create চাপুন।
  3. উপরে নতুন project সিলেক্ট আছে কিনা দেখে নিন। তারপর Google Drive API পেজে গিয়ে Enable চাপুন।
After Enable you land on the Drive API page. Use OAuth consent screen in the left menu.
After Enable you land on the Drive API page. Use OAuth consent screen in the left menu.Enable-এর পর Drive API পেজ আসে। বাম মেনুর OAuth consent screen ব্যবহার করুন।

Free. Google does not ask for a card for this.

সম্পূর্ণ ফ্রি। এর জন্য Google কোনো কার্ড চায় না।

3Create the OAuth clientOAuth client তৈরি করুন

  1. In Google Auth Platform open Clients → Create client (or click Create OAuth client on the Overview page).
  2. Application type: Web application.
  3. Under Authorized redirect URIs click Add URI and paste exactly:
  1. Google Auth Platform-এ Clients → Create client খুলুন (অথবা Overview পেজের Create OAuth client চাপুন)।
  2. Application type: Web application।
  3. Authorized redirect URIs-এ Add URI চাপুন এবং হুবহু এটি পেস্ট করুন:
Clients → Create client: Application type Web application.
Clients → Create client: Application type Web application.Clients → Create client: Application type Web application।
Authorized redirect URIs: exactly https://gmirror.xkaf.org/
Authorized redirect URIs: exactly https://gmirror.xkaf.org/Authorized redirect URIs: হুবহু https://gmirror.xkaf.org/
https://gmirror.xkaf.org/
  1. Click Create. Copy the Client ID and Client secret right away (or click Download JSON). You will paste them into the generator. Google shows the secret only in this dialog; if you lose it, open the client and click Add secret.
  1. Create চাপুন। সাথে সাথে Client ID আর Client secret কপি করুন (অথবা Download JSON চাপুন), জেনারেটরে লাগবে। Secret শুধু এই dialog-এ একবার দেখায়; হারিয়ে গেলে client খুলে Add secret চাপুন।
Copy the Client ID and Client secret now. The secret is shown only once.
Copy the Client ID and Client secret now. The secret is shown only once.এখনই Client ID আর Client secret কপি করুন। Secret একবারই দেখায়।

The trailing / matters. A missing slash causes the redirect_uri_mismatch error.

শেষের / জরুরি। এটা না দিলে redirect_uri_mismatch error আসে।

4Build your worker.jsworker.js তৈরি করুন

Open the generator and go through the five steps:

জেনারেটর খুলে পাঁচটি ধাপ পূরণ করুন:

  1. Google login: paste the Client ID and secret, keep Read-only, click Sign in with Google and allow access. Google may show “Google hasn't verified this app”: click Advanced → Go to … (unsafe). That is normal, because it is your own app.
  2. Drives: click Load my Shared Drives, or add My Drive, or paste any folder link. Give each a name. A password is optional.
  3. Site look: title, description and colors. You can change them later.
  4. Security: set an admin password so you can use /admin later. Leave the rest as it is if unsure.
  5. Download: click Generate worker.js and download the file.
  1. Google লগইন: Client ID আর secret বসান, Read-only রাখুন, Google দিয়ে সাইন ইন চেপে অনুমতি দিন। Google “Google hasn't verified this app” দেখাতে পারে: Advanced → Go to … (unsafe) চাপুন। এটা স্বাভাবিক, কারণ app-টা আপনার নিজের।
  2. ড্রাইভ: Shared Drive লোড করুন চাপুন, অথবা My Drive বা যেকোনো ফোল্ডার লিংক যোগ করুন। প্রতিটির নাম দিন। পাসওয়ার্ড ঐচ্ছিক।
  3. সাইটের রূপ: নাম, বিবরণ আর রং। পরে বদলানো যাবে।
  4. নিরাপত্তা: একটি admin পাসওয়ার্ড দিন, যাতে পরে /admin ব্যবহার করতে পারেন। নিশ্চিত না হলে বাকি সব যেমন আছে রাখুন।
  5. ডাউনলোড: worker.js তৈরি করুন চেপে ফাইলটি ডাউনলোড করুন।

Keep worker.js private. It contains your Google credentials. Never post it publicly or upload it to a public code repository.

worker.js গোপন রাখুন। এতে আপনার Google credentials আছে। কখনো পাবলিকলি শেয়ার বা পাবলিক কোড রিপোজিটরিতে আপলোড করবেন না।

5Deploy on Cloudflare WorkersCloudflare Workers-এ deploy করুন

  1. Log in to Cloudflare → Workers & Pages → Create.
  2. Choose Create Worker (Start with Hello World), give it a name like my-mirror, click Deploy.
  3. Click Edit code. Select all the sample code, delete it, paste your whole worker.js.
  4. Click Deploy. Open the ….workers.dev link. Your mirror is live!
  1. Cloudflare → Workers & Pages → Create-এ লগইন করুন।
  2. Create Worker (Start with Hello World) বেছে নিন, my-mirror-এর মতো একটি নাম দিয়ে Deploy চাপুন।
  3. Edit code চাপুন। নমুনা কোড সব সিলেক্ট করে মুছে দিন, তারপর পুরো worker.js পেস্ট করুন।
  4. Deploy চাপুন। ….workers.dev লিংকটি খুলুন। আপনার মিরর চালু!

Prefer the command line? (Wrangler)

কমান্ড লাইন পছন্দ? (Wrangler)

Put worker.js in a folder with this wrangler.toml:

worker.js-এর পাশে এই wrangler.toml ফাইলটি রাখুন:

name = "my-mirror"
main = "worker.js"
compatibility_date = "2025-06-01"

[[kv_namespaces]]
binding = "XKAF_KV"
id = "PASTE_KV_ID_HERE"
npm i -g wrangler
wrangler login
wrangler kv namespace create XKAF_KV   # paste the id into wrangler.toml
wrangler deploy

6Add KV storage (recommended)KV storage যোগ করুন (প্রস্তাবিত)

KV lets you edit settings live from /admin and see download statistics.

KV থাকলে /admin থেকে সরাসরি সেটিং বদলানো যায় আর ডাউনলোড পরিসংখ্যান দেখা যায়।

  1. In Cloudflare go to Storage & Databases → KV → Create. Any name is fine.
  2. Open your Worker → Settings → Bindings → Add → KV namespace.
  3. Variable name: XKAF_KV (exactly). Pick the namespace you just made. Deploy.
  1. Cloudflare-এ Storage & Databases → KV → Create-এ যান। যেকোনো নাম দিন।
  2. আপনার Worker খুলে Settings → Bindings → Add → KV namespace-এ যান।
  3. Variable name হুবহু XKAF_KV দিন। এইমাত্র বানানো namespace বেছে নিয়ে Deploy চাপুন।

7Use your own domain (optional)নিজের ডোমেইন ব্যবহার (ঐচ্ছিক)

  1. Your domain must be added to the same Cloudflare account.
  2. Open your Worker → Settings → Domains & Routes → Add → Custom domain.
  3. Type e.g. files.example.com and click Add domain. DNS and SSL are set up for you within a few minutes.
  1. আপনার ডোমেইন একই Cloudflare অ্যাকাউন্টে যুক্ত থাকতে হবে।
  2. Worker খুলে Settings → Domains & Routes → Add → Custom domain-এ যান।
  3. যেমন files.example.com লিখে Add domain চাপুন। কয়েক মিনিটে DNS আর SSL নিজে থেকেই সেট হয়ে যাবে।

8Manage it from /admin/admin থেকে পরিচালনা

Open https://your-mirror/admin and log in with your admin password. From there you can:

https://your-mirror/admin খুলে admin পাসওয়ার্ড দিয়ে লগইন করুন। সেখান থেকে আপনি পারবেন:

  • Add, rename, hide or password-protect drives
  • Change title, colors, logo, announcement banner and homepage text
  • Turn features on or off (search, video player, previews…)
  • See download statistics, purge the cache, back up settings
  • ড্রাইভ যোগ, নাম বদল, লুকানো বা পাসওয়ার্ড দেওয়া
  • নাম, রং, লোগো, ঘোষণা ব্যানার আর হোমপেজ লেখা বদলানো
  • ফিচার চালু/বন্ধ করা (সার্চ, ভিডিও প্লেয়ার, প্রিভিউ…)
  • ডাউনলোড পরিসংখ্যান দেখা, cache purge করা, সেটিং ব্যাকআপ নেওয়া

Lock a single folder: put a file named .password inside it. The text in that file becomes the folder's password.

একটি ফোল্ডার লক করতে: ফোল্ডারের ভিতরে .password নামে একটি ফাইল রাখুন। ফাইলের লেখাটাই হবে ফোল্ডারের পাসওয়ার্ড।

Advanced: keep secrets out of the codeঅ্যাডভান্সড: কোডের বাইরে secret রাখা

Tick Keep secrets out of the code in step 4 if you store worker.js in Git. The generator then shows values to add in your Worker under Settings → Variables and Secrets → Add → Secret:

worker.js Git-এ রাখলে ধাপ ৪-এ কোডের বাইরে secret রাখুন টিক দিন। জেনারেটর তখন কিছু মান দেখাবে, যেগুলো Worker-এর Settings → Variables and Secrets → Add → Secret-এ যোগ করবেন:

SecretWhat it isএটা কী
CLIENT_SECRETYour Google client secretআপনার Google client secret
REFRESH_TOKENToken from the Google sign-inGoogle সাইন ইন থেকে পাওয়া token
SESSION_SECRETRandom value that signs cookies and linksকুকি ও লিংক সাইন করার random মান
ADMIN_PASSWORDOptional: admin password (overrides the one in code)ঐচ্ছিক: admin পাসওয়ার্ড (কোডেরটার বদলে এটা চলবে)

Updating to a new versionনতুন ভার্সনে আপডেট

Settings saved in /admin live in KV and survive updates. The easiest way:

/admin-এ সেভ করা সেটিং KV-তে থাকে, আপডেটে মুছে যায় না। সবচেয়ে সহজ উপায়:

  1. In /admin → Backup, click Download settings.json.
  2. Generate a fresh worker.js here and paste it into your Worker (Edit code → Deploy).
  3. If anything is missing, use Import JSON in /admin → Backup and press Save.
  1. /admin → Backup-এ Download settings.json চাপুন।
  2. এখানে নতুন করে worker.js তৈরি করে Worker-এ পেস্ট করুন (Edit code → Deploy)।
  3. কিছু হারিয়ে গেলে /admin → Backup-এ Import JSON দিয়ে ফাইলটি দিন, তারপর Save চাপুন।

Problems & fixesসমস্যা ও সমাধান

“Error 400: redirect_uri_mismatch”“Error 400: redirect_uri_mismatch”

The redirect URI in your Google client is not exactly https://gmirror.xkaf.org/. Fix it in Clients, save, wait a minute and try again.

Google client-এ redirect URI হুবহু https://gmirror.xkaf.org/ নয়। Clients-এ ঠিক করে সেভ করুন, এক মিনিট অপেক্ষা করে আবার চেষ্টা করুন।

“Google did not return a refresh token”“Google did not return a refresh token”

Remove the app at myaccount.google.com/permissions, then sign in again in step 1.

myaccount.google.com/permissions থেকে app-টি সরিয়ে দিন, তারপর ধাপ ১-এ আবার সাইন ইন করুন।

“Publish app” is greyed out“Publish app” ধূসর হয়ে আছে

In Branding, set the home page to https://gmirror.xkaf.org/, the privacy policy to https://gmirror.xkaf.org/privacy.html and authorized domain xkaf.org, then Save and reload Audience (step 2).

Branding-এ home page https://gmirror.xkaf.org/, privacy policy https://gmirror.xkaf.org/privacy.html আর authorized domain xkaf.org দিন, তারপর Save চেপে Audience রিলোড করুন (ধাপ ২)।

The mirror stopped working after about a weekপ্রায় এক সপ্তাহ পর মিরর কাজ করছে না

Your app was still in Testing. Click Publish app (step 2), create a new worker.js and deploy it again.

আপনার app তখনো Testing-এ ছিল। Publish app চাপুন (ধাপ ২), তারপর নতুন worker.js বানিয়ে আবার deploy করুন।

“Access blocked” or “This app is blocked”“Access blocked” বা “This app is blocked”

Usually the app is still in Testing with no test users. Open Audience: if Publish app is greyed out, finish Branding first (step 2), then publish. Also make sure Audience is External and the Google Drive API is enabled in the same project as your client.

সাধারণত app তখনো Testing-এ থাকে এবং কোনো test user নেই। Audience খুলুন: Publish app ধূসর থাকলে আগে Branding শেষ করুন (ধাপ ২), তারপর publish করুন। আর Audience External আছে কিনা, এবং একই project-এ Google Drive API enabled কিনা দেখে নিন।

Files show but downloads fail with 403ফাইল দেখা যায়, কিন্তু ডাউনলোডে 403 আসে

Google limits very popular files for a while (quota). Wait some hours, or copy the file again in Drive so it gets a fresh quota.

খুব জনপ্রিয় ফাইলে Google কিছু সময়ের জন্য সীমা দেয় (quota)। কয়েক ঘণ্টা অপেক্ষা করুন, অথবা Drive-এ ফাইলটির নতুন কপি বানান।

/admin says “No KV namespace is bound”/admin-এ “No KV namespace is bound” দেখাচ্ছে

Add the KV binding named exactly XKAF_KV (step 6) and deploy again.

হুবহু XKAF_KV নামে KV binding যোগ করুন (ধাপ ৬) এবং আবার deploy করুন।

I changed files in Drive but the site shows old onesDrive-এ ফাইল বদলেছি, কিন্তু সাইটে পুরনোটা দেখাচ্ছে

Listings are cached for a short time. Use Purge all caches in /admin to refresh right away.

লিস্ট কিছুক্ষণ cache থাকে। সাথে সাথে আপডেট পেতে /admin-এ Purge all caches চাপুন।

Cloudflare free plan limitsCloudflare ফ্রি প্ল্যানের সীমা

LimitসীমাWhat it means for youআপনার জন্য এর মানে
100,000 requests / dayদিনে ১,০০,০০০ requestA page view is about 2 requests. A download is 1, whatever the file size.একটি পেজ ভিউ প্রায় ২টি request। একটি ডাউনলোড ১টি, ফাইল যত বড়ই হোক।
10 ms CPU / requestপ্রতি request-এ ১০ ms CPUFiles are streamed straight through, so big files are fine.ফাইল সরাসরি stream হয়, তাই বড় ফাইলেও সমস্যা নেই।
KV: 1,000 writes / dayKV: দিনে ১,০০০ writeThe mirror writes rarely (stats every few minutes, admin saves).মিরর খুব কম write করে (কয়েক মিনিট পর পর stats, admin সেভ)।