আপনার ফাইলগুলি একটি Cloud Storage বাকেটে সংরক্ষণ করা হয়। এই বাকেটে থাকা ফাইলগুলি একটি শ্রেণিবদ্ধ কাঠামোতে উপস্থাপিত হয়, ঠিক যেমন আপনার স্থানীয় হার্ড ডিস্কের ফাইল সিস্টেম, অথবা Firebase Realtime Database ডেটা। একটি ফাইলের রেফারেন্স তৈরি করে, আপনার অ্যাপটি এতে অ্যাক্সেস পায়। এই রেফারেন্সগুলি ডেটা আপলোড বা ডাউনলোড করতে, মেটাডেটা পেতে বা আপডেট করতে বা ফাইলটি মুছে ফেলতে ব্যবহার করা যেতে পারে। একটি রেফারেন্স হয় একটি নির্দিষ্ট ফাইলকে নির্দেশ করতে পারে অথবা শ্রেণিবদ্ধের একটি উচ্চ স্তরের নোডকে নির্দেশ করতে পারে।
যদি আপনি Firebase Realtime Database ব্যবহার করে থাকেন, তাহলে এই পাথগুলি আপনার কাছে খুব পরিচিত মনে হবে। তবে, আপনার ফাইল ডেটা Cloud Storage সংরক্ষিত আছে, Realtime Database নয় ।
একটি রেফারেন্স তৈরি করুন
একটি ফাইল আপলোড, ডাউনলোড, অথবা মুছে ফেলার জন্য, অথবা এর মেটাডেটা পেতে বা আপডেট করার জন্য একটি রেফারেন্স তৈরি করুন। একটি রেফারেন্সকে ক্লাউডে থাকা একটি ফাইলের দিকে নির্দেশক হিসেবে ভাবা যেতে পারে। রেফারেন্সগুলি হালকা, তাই আপনি যতগুলি প্রয়োজন ততগুলি তৈরি করতে পারেন। এগুলি একাধিক ক্রিয়াকলাপের জন্য পুনরায় ব্যবহারযোগ্য।
 আপনার Firebase অ্যাপের storage পরিষেবা থেকে GetReferenceFromUrl() পদ্ধতিতে কল করে এবং gs://<your-cloud-storage-bucket> ফর্মের একটি URL পাস করে রেফারেন্স তৈরি করা হয়। আপনি Firebase কনসোলের স্টোরেজ বিভাগে এই URLটি খুঁজে পেতে পারেন।
// Get a reference to the storage service, using the default Firebase App Storage* storage = Storage::GetInstance(app); // Create a Cloud Storage reference from our storage service StorageReference storage_ref = storage->GetReferenceFromUrl("gs://<your-cloud-storage-bucket>");
 আপনি বিদ্যমান রেফারেন্সে child পদ্ধতি ব্যবহার করে গাছের নীচের কোনও অবস্থানে, যেমন 'images/space.jpg' , একটি রেফারেন্স তৈরি করতে পারেন।
// Create a child reference // images_ref now points to "images" StorageReference images_ref = storage_ref.Child("images"); // Child references can also take paths delimited by '/' // space_ref now points to "images/space.jpg" // images_ref still points to "images" StorageReference space_ref = storage_ref.Child("images/space.jpg"); // This is equivalent to creating the full reference StorageReference space_ref = storage.GetReferenceFromUrl("gs://<your-cloud-storage-bucket>/images/space.jpg");
রেফারেন্স সহ নেভিগেট করুন
 আমাদের ফাইল হায়ারার্কিতে আপনি Parent এবং Root পদ্ধতি ব্যবহার করে উপরে যেতে পারেন। Parent এক স্তর উপরে নেভিগেট করে, যখন Root সম্পূর্ণভাবে উপরে নেভিগেট করে।
// Parent allows us to move to the parent of a reference // images_ref now points to 'images' StorageReference images_ref = space_ref.Parent(); // Root allows us to move all the way back to the top of our bucket // root_ref now points to the root StorageReference root_ref = space_ref.Root();
 Child , Parent , এবং Root একাধিকবার একসাথে শৃঙ্খলিত করা যেতে পারে, কারণ প্রতিটি একটি রেফারেন্স প্রদান করে। ব্যতিক্রম হল Root এর Parent , যা একটি অবৈধ StorageReference ।
// References can be chained together multiple times // earth_ref points to "images/earth.jpg" StorageReference earth_ref = space_ref.Parent().Child("earth.jpg"); // null_ref is null, since the parent of root is an invalid StorageReference StorageReference null_ref = space_ref.Root().Parent();
রেফারেন্স পদ্ধতি
 full_path , name , এবং bucket পদ্ধতি ব্যবহার করে আপনি রেফারেন্সগুলি পরিদর্শন করতে পারেন যাতে তারা যে ফাইলগুলি নির্দেশ করে তা আরও ভালভাবে বুঝতে পারে। এই পদ্ধতিগুলি ফাইলের সম্পূর্ণ পথ, নাম এবং bucket পায়।
// Reference's path is: "images/space.jpg" // This is analogous to a file path on disk space_ref.full_path(); // Reference's name is the last segment of the full path: "space.jpg" // This is analogous to the file name space_ref.name(); // Reference's bucket is the name of the Cloud Storage bucket where files are stored space_ref.bucket();
রেফারেন্সের উপর সীমাবদ্ধতা
রেফারেন্স পাথ এবং নামগুলিতে বৈধ ইউনিকোড অক্ষরের যেকোনো ক্রম থাকতে পারে, তবে কিছু বিধিনিষেধ আরোপ করা হয়েছে যার মধ্যে রয়েছে:
- UTF-8 এনকোড করার সময় reference.fullPath এর মোট দৈর্ঘ্য ১ থেকে ১০২৪ বাইটের মধ্যে হতে হবে।
- কোনও ক্যারেজ রিটার্ন বা লাইন ফিড অক্ষর নেই।
-  #,[,],*, অথবা?ব্যবহার করা এড়িয়ে চলুন, কারণ এগুলি Firebase Realtime Database বা gsutil এর মতো অন্যান্য টুলের সাথে ভালোভাবে কাজ করে না।
সম্পূর্ণ উদাহরণ
Storage* storage = Storage::GetInstance(app); // Points to the root reference StorageReference storage_ref = storage->GetReferenceFromUrl("gs://<your-bucket-name>"); // Points to "images" StorageReference images_ref = storage_ref.Child("images"); // Points to "images/space.jpg" // Note that you can use variables to create child values std::string filename = "space.jpg"; StorageReference space_ref = images_ref.Child(filename); // File path is "images/space.jpg" std::string path = space_ref.full_path() // File name is "space.jpg" std::string name = space_ref.name() // Points to "images" StorageReference images_ref = space_ref.Parent();
পরবর্তী পদক্ষেপ
এরপর, আসুন শিখি কিভাবে Cloud Storage ফাইল আপলোড করতে হয়।