Skip to main content

Delete Object

Permanently deletes an object (file) from a Google Cloud Storage bucket.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • GCS Client Id - The client identifier obtained from the Connect node. Optional if credentials are provided directly.
  • Bucket Name - The name of the bucket containing the object to delete.
  • Object Name - The name (path) of the object to delete from the bucket.

Options

  • Credentials - Google Cloud service account credentials (optional). Use this instead of GCS Client Id for direct authentication without Connect node.

How It Works

The Delete Object node removes an object from a Google Cloud Storage bucket. When executed, the node:

  1. Establishes connection using either GCS Client Id or provided credentials
  2. Validates the bucket name and object name
  3. Locates the specified object in the bucket
  4. Permanently deletes the object (or creates a delete marker if versioning is enabled)
  5. Completes successfully if object is deleted or doesn't exist

Example

Delete a Single File

// After Connect node or with direct credentials
// Input:
// Bucket Name: "my-data-bucket"
// Object Name: "temp/old-file.txt"

// The object is permanently deleted from the bucket

Delete with Folder Path

// Delete object with folder-like path
// Input:
// Bucket Name: "backup-bucket"
// Object Name: "backups/2023/december/backup-old.zip"

// Deletes the specific object
// Note: Empty "folders" are automatically removed

Cleanup Old Files in Loop

// In JavaScript node, prepare list of old files
const oldFiles = [
"logs/2023-01-01.log",
"logs/2023-01-02.log",
"logs/2023-01-03.log"
];
message.filesToDelete = oldFiles;

// Use Loop node to iterate through files
// Each iteration: Delete Object with current file name

Conditional Deletion

// Delete file if it meets certain criteria
// First, use List Objects to get file details
// Then use Condition node to check criteria
// Finally, Delete Object if condition is true

if (message.fileSize > 1000000) { // File larger than 1MB
// Proceed to Delete Object node
}

Requirements

  • Either a valid GCS Client Id from Connect node OR credentials provided directly
  • Valid bucket name that exists in Google Cloud Storage
  • Appropriate IAM permissions:
    • storage.objects.delete permission
    • roles/storage.objectAdmin or higher
  • Object name to delete (object doesn't need to exist)

Error Handling

The node will return specific errors in the following cases:

Error CodeDescription
ErrInvalidArgBucket Name or Object Name is empty or invalid

Common error scenarios:

  • Empty or invalid GCS Client Id without credentials
  • Empty or invalid Bucket Name
  • Empty or invalid Object Name
  • Bucket doesn't exist
  • Insufficient permissions to delete objects
  • Google Cloud Storage service errors
  • Network connectivity issues

Note: If the object doesn't exist, the operation succeeds without error.

Usage Notes

  • Object names can include folder-like paths using forward slashes
  • This operation is immediate and cannot be undone
  • The node succeeds even if the object doesn't exist (idempotent operation)
  • Once deleted, objects cannot be recovered unless versioning is enabled
  • If versioning is enabled, deletion creates a delete marker instead of permanent deletion
  • Deleted objects free up storage space immediately
  • No confirmation is required - deletion happens immediately
  • Bulk deletions should be done carefully with proper validation

Tips for Effective Use

  • Always validate object names before deletion
  • Use List Objects to verify file existence before deleting
  • Implement confirmation logic for critical file deletions
  • Use with Loop nodes to delete multiple files
  • Consider archiving instead of deleting for important data
  • Test deletion logic with non-critical files first
  • Implement logging to track deleted files
  • Use condition nodes to add deletion criteria
  • Enable versioning on buckets for important data
  • Consider lifecycle policies for automatic cleanup

Common Errors and Solutions

Error: "Bucket Name cannot be empty"

  • Solution: Ensure bucket name is properly set in inputs
  • Check variable bindings and message context

Error: "Object Name cannot be empty"

  • Solution: Verify the object name is correctly specified
  • Check for empty strings in variables

Insufficient permissions error

  • Solution: Verify service account has storage.objects.delete permission
  • Check bucket IAM policies
  • Ensure the service account has objectAdmin role or higher

Object still appears after deletion

  • Solution: Wait a few seconds for eventual consistency
  • Refresh the bucket listing
  • Check if versioning is enabled (object may be archived)

Deletion succeeds but storage not freed

  • Solution: Check if object versioning is enabled
  • Delete all versions of the object
  • Review bucket lifecycle policies

Use Cases

Temporary File Cleanup

  • Delete temporary files after processing
  • Clean up intermediate processing results
  • Remove expired cache files

Log Rotation

  • Delete old log files based on date
  • Implement log retention policies
  • Free up storage from outdated logs

Data Lifecycle Management

  • Remove files after successful processing
  • Delete duplicate or redundant files
  • Clean up test data after completion

Batch Processing

  • Delete source files after successful transformation
  • Remove files after archiving to cold storage
  • Clean up failed upload attempts

Storage Optimization

  • Delete obsolete backups
  • Remove large files no longer needed
  • Free up quota in storage buckets

Automated Maintenance

  • Schedule cleanup of temporary directories
  • Delete files older than retention period
  • Remove processed files from staging areas

Important Warnings

warning

Deletion is permanent! Unless versioning is enabled on the bucket, deleted objects cannot be recovered. Always verify the object name before deletion.

tip

For critical data, consider:

  • Enabling object versioning on your bucket
  • Creating backups before deletion
  • Using lifecycle policies instead of manual deletion
  • Implementing soft-delete patterns with archive buckets