Class

GcsService

GcsService()

Google Cloud Storage Service Handles file uploads and management in Google Cloud Storage with automatic image optimization.

Constructor

# new GcsService()

Instantiate the GCS client with configured credentials and bucket.

View Source services/gcs.service.js, line 11

Classes

GcsService

Methods

# async avatarExists(avatarUrl) → {Promise.<boolean>}

Check if an avatar exists in GCS.

Parameters:
Name Type Description
avatarUrl string

The public URL of the avatar.

View Source services/gcs.service.js, line 211

True if the file exists.

Promise.<boolean>

# async deleteAvatar(avatarUrl) → {Promise.<boolean>}

Delete an avatar from GCS.

Parameters:
Name Type Description
avatarUrl string

The public URL of the avatar to delete.

View Source services/gcs.service.js, line 141

True when deleted successfully.

Promise.<boolean>

# async deleteUserAvatars(userId) → {Promise.<number>}

Delete all avatars for a specific user.

Parameters:
Name Type Description
userId string

The user ID.

View Source services/gcs.service.js, line 182

Number of files deleted.

Promise.<number>

# async getAvatarMetadata(avatarUrl) → {Promise.<(FileMetadata|null)>}

Get avatar metadata.

Parameters:
Name Type Description
avatarUrl string

The public URL of the avatar.

View Source services/gcs.service.js, line 241

File metadata response.

Promise.<(FileMetadata|null)>

# async healthCheck() → {Promise.<boolean>}

Health check for GCS connection.

View Source services/gcs.service.js, line 277

True if GCS is accessible.

Promise.<boolean>

# async uploadAvatar(userId, base64Image) → {Promise.<string>}

Upload an avatar image to GCS with resizing and compression.

Parameters:
Name Type Description
userId string

The user ID.

base64Image string

Base64 encoded image string.

View Source services/gcs.service.js, line 40

The public URL of the uploaded avatar.

Promise.<string>