Skip to content

/system/blobs

Path: /system/blobs
Namespace: system
Resource: blobs

Overview

The Blob resource in the system namespace provides system administrators with access to blob storage across all domains for system-wide file management. Blobs can have associated attachments.

Key Difference from Admin: The system namespace provides cross-tenant access for system administrators, while the admin namespace is scoped to a single domain.

Relationships

Blob connects to:

  • Attachment[] (attachments) - Attachments using this blob
  • Domain (host_id) - Tenant domain

Key Features

  • System-Wide Access: Access to all blobs across all tenants
  • Cross-Tenant Management: Manage blobs from all tenants
  • File Storage: Store and manage files via blob storage
  • Attachment Association: Blobs can have associated attachments

Available Operations

List Blobs (GET)

Endpoint: GET /system/blobs.json

Query Parameters:

  • q[field_predicate]=value - Ransack query filters for advanced filtering
  • page=N - Page number for pagination
  • per_page=N - Items per page (default: 25)

Request Examples:

bash
curl -X GET "https://your-company.erpax.com/system/blobs.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

JavaScript Example:

javascript
const response = await fetch('/system/blobs.json', {
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});
const data = await response.json();

Response (200 OK):

json
{
  "blobs": [
    {
      "id": 1,
      "key": "abc123def456",
      "filename": "document.pdf",
      "content_type": "application/pdf",
      "byte_size": 102400,
      "checksum": "abc123...",
      "created_at": "2024-01-15T10:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 25,
    "total_pages": 1,
    "total_count": 5
  }
}

Show Blob (GET /:id)

Endpoint: GET /system/blobs/:id.json

Request Example:

bash
curl -X GET "https://your-company.erpax.com/system/blobs/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

Response (200 OK):

json
{
  "blob": {
    "id": 1,
    "key": "abc123def456",
    "filename": "document.pdf",
    "content_type": "application/pdf",
    "byte_size": 102400,
    "checksum": "abc123...",
    "created_at": "2024-01-15T10:00:00Z",
    "updated_at": "2024-01-15T12:00:00Z"
  }
}

Create Blob (POST)

Endpoint: POST /system/blobs.json

Request Example:

bash
curl -X POST "https://your-company.erpax.com/system/blobs.json" \
  -H "Content-Type: multipart/form-data" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -F "blob[file][email protected]"

Response (201 Created):

json
{
  "blob": {
    "id": 2,
    "key": "xyz789abc123",
    "filename": "document.pdf",
    "content_type": "application/pdf",
    "byte_size": 102400,
    "created_at": "2024-01-15T14:30:00Z"
  }
}

Update Blob (PATCH /:id)

Endpoint: PATCH /system/blobs/:id.json

Request Example:

bash
curl -X PATCH "https://your-company.erpax.com/system/blobs/1.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "blob": {
      "filename": "updated_document.pdf"
    }
  }'

Response (200 OK):

json
{
  "blob": {
    "id": 1,
    "filename": "updated_document.pdf",
    "updated_at": "2024-01-15T15:00:00Z"
  }
}

Delete Blob (DELETE /:id)

Endpoint: DELETE /system/blobs/:id.json

Request Example:

bash
curl -X DELETE "https://your-company.erpax.com/system/blobs/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

Response (204 No Content):

(empty response)

Member Actions

Custom actions available on individual blobs via API:

Manage Attachments

Endpoint: GET /system/blobs/:id/attachments.json

Description: Access blob attachments via the nested resource.

Request Example:

bash
curl -X GET "https://your-company.erpax.com/system/blobs/123/attachments.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

Response (200 OK):

json
{
  "attachments": [
    {
      "id": 1,
      "filename": "document.pdf",
      "attachable_type": "Invoice",
      "attachable_id": 123
    }
  ]
}

See Blob Attachments for complete attachment management operations.

Scopes

No custom scopes are configured (uses default 'all' scope).

Filters

Available filters for searching and filtering blobs:

  • filename_cont - Text filter - Search by filename (contains)
  • content_type - Select filter - Filter by content type
  • key - Text filter - Filter by blob key
  • created_at - Date filter - Filter by creation date
  • updated_at - Date filter - Filter by update date

Business Rules

  • System-Wide Access: System namespace provides access to all blobs across all tenants
  • Cross-Tenant Management: System administrators can manage blobs across all tenants
  • File Storage: Blobs store files with metadata (filename, content_type, byte_size, checksum)
  • Attachment Association: Blobs can have associated attachments

Nested Resources

Released under an open source license.