26 Object Reference

This chapter explains how Oracle Backend for Firebase's Object Storage organizes and references files. It covers path conventions, bucket structures, and how files are linked to documents using storageRef. Understanding this structure is essential for managing uploads, downloads, and file access across DBFS and OCI Object Storage backends.

26.1 Understanding Object Reference

To upload or download files, delete files, or get or update metadata, you must create a reference to the file you want to operate on. A reference can be thought of as a pointer to a file that Oracle Backend for Firebase uses to organize a file within Object Storage. References are also reusable for multiple operations. These references are used both in the Console and SDK to locate and manage files.

import { ref } from "fusabase/storage";

const recipeRef = ref(storage, "recipes/Scott/Cookies/main.jpg");

console.log(recipeRef.fullPath); // "recipes/Scott/Cookies/main.jpg"
console.log(recipeRef.name);     // "main.jpg"
console.log(recipeRef.bucket);   // "<your-bucket>"
console.log(recipeRef.parent.fullPath); // "recipes/Scott/Cookies"
const ref = storage.ref("recipes/Scott/Cookies/main.jpg");

console.log(ref.fullPath); // "recipes/Scott/Cookies/main.jpg"
console.log(ref.name);     // "main.jpg"
console.log(ref.bucket);   // "<your-bucket>"
console.log(ref.parent.fullPath); // "recipes/Scott/Cookies"
import com.oracle.mobile.fusabase.storage.Storage;
import com.oracle.mobile.fusabase.storage.StorageReference;
import android.util.Log;

Storage storage = Storage.getInstance();

// Create storage reference
StorageReference recipeRef = storage.getReference("recipes/Scott/Cookies/main.jpg");

// Access reference properties (equivalent to JavaScript)
Log.d(TAG, "Full Path: " + recipeRef.getPath());     // "recipes/Scott/Cookies/main.jpg"
Log.d(TAG, "Name: " + recipeRef.getName());          // "main.jpg"
Log.d(TAG, "Bucket: " + recipeRef.getBucket());      // "<your-bucket>"
Log.d(TAG, "Parent Full Path: " + recipeRef.getParent().getPath()); // "recipes/Scott/Cookies"
import FusabaseStorage

let storage = Storage.storage()

let recipeRef = storage.reference(withPath: "recipes/Scott/Cookies/main.jpg")

print("Path:", recipeRef.fullPath)     // "recipes/Scott/Cookies/main.jpg"
print("Name:", recipeRef.name)         // "main.jpg"
print("Bucket:", recipeRef.bucket)     // "<your-bucket>"
if let parentRef = recipeRef.parent() {
    print("Parent path:", parentRef.fullPath) // "recipes/Scott/Cookies"
}
final recipeRef =
    storage.ref('recipes/Scott/Cookies/main.jpg');

print(recipeRef.fullPath);   // "recipes/Scott/Cookies/main.jpg"
print(recipeRef.name);       // "main.jpg"
print(recipeRef.bucket);     // "<your-bucket>.appspot.com"
print(recipeRef.parent?.fullPath);

Bucket Naming and Structure

  • Buckets are defined at the project level using the Console.

  • Each bucket can contain multiple folders and files.

  • Buckets are backend-agnostic and work with both DBFS and OCI OBJS.

Note:

OCI Object Storage uses a flat namespace; folders are simulated through prefixes.

26.2 Creating a Reference to a Document

Create a reference to upload, download, or delete a file, or to get or update its metadata.

import { ref } from "fusabase/storage";

// Reference to a recipe image
const recipeImageRef = ref(storage, "recipes/Scott/Cookies/main.jpg");
// Reference to a recipe image
const recipeImageRef = storage.ref("recipes/Scott/Cookies/main.jpg");
import com.oracle.mobile.fusabase.storage.Storage;
import com.oracle.mobile.fusabase.storage.StorageReference;

// Get storage instance
Storage storage = Storage.getInstance();

// Reference to a recipe image
StorageReference recipeImageRef = storage.getReference().child("recipes/Scott/Cookies/main.jpg");
import FusabaseStorage

let storage = Storage.storage()
let recipeImageRef = storage.reference(withPath: "recipes/Scott/Cookies/main.jpg")
// Reference to a recipe image
final recipeImageRef =
    storage.ref('recipes/Scott/Cookies/main.jpg');

26.3 Navigating Different Paths Using a Reference

The DBFS pathing supports true folder structures and files are stored in hierarchical paths. For example, Example: users/Scott/recipes/Cookies/photos/photo1.png.

The OCI OBJS pathing uses object prefixes to simulate folders and No actual folder hierarchy exists. For example, users/Scott/recipes/Cookies/photos/photo1.png is treated as a single object key.

// Reference to a recipe image
const recipeImageRef = storage.ref("recipes/Scott/Cookies/main.jpg");

// Parent → "recipes/Scott/Cookies"
const recipeFolderRef = recipeImageRef.parent;

// Root → bucket root
const rootRef = recipeImageRef.root;
import { ref } from "fusabase/storage";

// Reference to a recipe image
const recipeImageRef = ref(storage, "recipes/Scott/Cookies/main.jpg");

// Parent → "recipes/Scott/Cookies"
const recipeFolderRef = recipeImageRef.parent;

// Root → bucket root
const rootRef = recipeImageRef.root;
import com.oracle.mobile.fusabase.storage.Storage;
import com.oracle.mobile.fusabase.storage.StorageReference;

// Get storage instance
Storage storage = Storage.getInstance();

// Reference to a recipe image
StorageReference recipeImageRef = storage.getReference("recipes/Scott/Cookies/main.jpg");

// Parent → "recipes/Scott/Cookies"
StorageReference recipeFolderRef = recipeImageRef.getParent();

// Root → bucket root
StorageReference rootRef = recipeImageRef.getRoot();
import FusabaseStorage

let storage = Storage.storage()

// Reference to a recipe image
let recipeImageRef = storage.reference(withPath: "recipes/Scott/Cookies/main.jpg")

// Parent → "recipes/Scott/Cookies"
let recipeFolderRef = recipeImageRef.parent()

// Root → bucket root
let rootRef = recipeImageRef.root()
// Reference to a recipe image
final recipeImageRef =
    storage.ref('recipes/Scott/Cookies/main.jpg');

// Parent → "recipes/Scott/Cookies"
final recipeFolderRef = recipeImageRef.parent;

// Root → bucket root
final rootRef = recipeImageRef.root;

26.4 Console-Based Path Navigation

The Oracle Backend for Firebase Console allows developers to:

  • Browse buckets and folders

  • View file paths and metadata

  • Copy storage references and URLs

  • Simulate folder navigation using path prefixes

See Also:

Storage Console Tasks for detailed steps on how to set up and enable storage services