dbp/relay-blob-connector-campusonline-dms-bundle
Install the Bundle
composer require dbp/relay-blob-connector-campusonline-dms-bundle
Ensure dbp/relay-blob-bundle is also installed as a dependency.
Enable the Bundle
Add to config/bundles.php:
return [
// ...
DigitalBlueprint\RelayBlobBundle\RelayBlobBundle::class => ['all' => true],
DigitalBlueprint\RelayBlobConnectorCampusonlineDmsBundle\RelayBlobConnectorCampusonlineDmsBundle::class => ['all' => true],
];
Configure the Connector
Add to config/packages/relay_blob.yaml:
relay_blob:
connectors:
campusonline_dms:
class: DigitalBlueprint\RelayBlobConnectorCampusonlineDmsBundle\Connector\CampusonlineDmsConnector
options:
api_url: '%env(CAMPUSONLINE_API_URL)%'
api_key: '%env(CAMPUSONLINE_API_KEY)%'
endpoint: 'object-store' # or custom endpoint if needed
First Use Case: Upload a File Inject the blob service and use the configured connector:
use DigitalBlueprint\RelayBlobBundle\Service\BlobService;
public function uploadFile(BlobService $blobService, UploadedFile $file)
{
$blob = $blobService->store($file, 'campusonline_dms');
return $blob->getUrl(); // Returns CAMPUSonline Object Store URL
}
File Upload/Download
BlobService to delegate operations to the CAMPUSonline connector.// Upload
$blob = $blobService->store($file, 'campusonline_dms');
// Download
$fileContent = $blobService->retrieve($blob->getId());
Metadata Handling
store() method:
$blob = $blobService->store($file, 'campusonline_dms', [
'metadata' => [
'author' => 'user@example.com',
'course_id' => 123,
],
]);
Error Handling
try {
$blob = $blobService->store($file, 'campusonline_dms');
} catch (\DigitalBlueprint\RelayBlobConnectorCampusonlineDmsBundle\Exception\ApiException $e) {
// Log or notify (e.g., CAMPUSonline API rate limit)
}
Integration with Laravel Filesystem
Storage facade with the relay-blob disk:
use Illuminate\Support\Facades\Storage;
Storage::disk('relay_blob')->put('file.pdf', $file);
Custom Endpoints
Override the default object-store endpoint in configuration:
options:
endpoint: 'custom-object-store-endpoint'
Event Listeners
Subscribe to blob.stored or blob.retrieved events for post-processing:
// src/EventListener/BlobListener.php
public function onBlobStored(BlobStoredEvent $event)
{
if ($event->getConnectorName() === 'campusonline_dms') {
// Log or trigger additional actions
}
}
Testing Mock the connector in tests:
$this->mock(DigitalBlueprint\RelayBlobConnectorCampusonlineDmsBundle\Connector\CampusonlineDmsConnector::class)
->shouldReceive('upload')
->andReturn(new Blob('test-id', 'campusonline_dms'));
API Key/URL Misconfiguration
CAMPUSONLINE_API_URL and CAMPUSONLINE_API_KEY are set in .env.https://your-campusonline-instance.com/api/object-store).Rate Limiting
File Size Limits
$blobService->store($file, 'campusonline_dms', ['stream' => true]);
Connector Naming Collisions
relay-blob connectors. Use unique names like campusonline_dms_v2.Enable API Logging
Add to config/packages/relay_blob.yaml:
debug: true
Logs will appear in var/log/dev.log.
Inspect Raw API Responses Override the connector to dump responses:
// src/Connector/CustomCampusonlineDmsConnector.php
public function upload($file, array $options)
{
$response = $this->client->upload(...);
\Log::debug('CAMPUSonline API Response:', ['response' => $response]);
return $response;
}
Validate Metadata CAMPUSonline may reject certain metadata keys. Test with minimal metadata first:
$blobService->store($file, 'campusonline_dms', ['metadata' => ['key' => 'value']]);
Custom Headers Extend the connector to add headers:
// src/Connector/CustomCampusonlineDmsConnector.php
protected function getHeaders(): array
{
return array_merge(parent::getHeaders(), [
'X-Custom-Header' => 'value',
]);
}
Pre/Post-Processing Use Symfony events to modify blobs before/after operations:
# config/services.yaml
services:
App\EventSubscriber\BlobSubscriber:
tags:
- { name: kernel.event_subscriber }
Fallback Connectors Implement a fallback chain if CAMPUSonline fails:
$blobService->store($file, ['campusonline_dms', 's3_fallback']);
How can I help you explore Laravel packages today?