Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AZURE_STORAGE_DOMAIN=azure_domain
AZURE_STORAGE_NAME=your_storage_name
AZURE_STORAGE_KEY=your_storage_key
AZURE_STORAGE_CONTAINER=your_container_name
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=<protocol>;AccountName=<account_name>;AccountKey=<account_key>;EndpointSuffix=<endpoint_suffix>

PUSHER_APP_ID=
PUSHER_APP_KEY=
Expand Down
1 change: 1 addition & 0 deletions app/Classes/Repositories/OrganisationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function updateDetailsWithInput(Organisation $org, array $input)
if (array_key_exists('url', $input)) {
$org->update([
'attribution_url' => $input['url'],
'attribution_file_name' => $input['imageUrl'],
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Classes/Transformers/OrganisationTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function transform(Organisation $model)
return [
'id' => $contributor->id,
'name' => $contributor->name,
'logo' => $contributor->logo,
'logo' => $contributor->logo ? $contributor->getLogoImageUrl() : null,
];
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/Classes/Transformers/WhatNowEntityTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function transform(WhatNowEntity $model)
return [
'id' => $contributor->id,
'name' => $contributor->name,
'logo' => $contributor->logo,
'logo' => $contributor->logo ? $contributor->getLogoImageUrl() : null,
];
});
}
Expand Down
32 changes: 32 additions & 0 deletions app/Http/Controllers/FileUploadController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class FileUploadController extends Controller
{
public function upload(Request $request)
{
try {

$request->validate([
'file' => 'required|file|mimes:jpg,png|max:10240',
]);


$file = $request->file('file');


$fileName = $file->getClientOriginalName();


$path = Storage::disk('azure')->putFileAs('', $file, $fileName);

return response()->json(['path' => $path], 200);
} catch (\Illuminate\Validation\ValidationException $e) {
return response()->json(['errors' => $e->errors()], 422);
}
}
}
18 changes: 18 additions & 0 deletions app/Models/Contributor.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,22 @@ public function organisation()
return $this->belongsTo(OrganisationDetails::class, 'org_detail_id');
}

public function getLogoPath()
{
return '/' . $this->logo;
}

public function getLogoImageUrl()
{
$filepath = $this->getLogoPath();

if (app()->environment('production')) {

//return valid url
return url(('https://'). config('app.bucket_name') . '.' . config('app.bucket_domain') . '/' . config('app.bucket_container') . $filepath);
}
//TODO configure for QA environment
return url(('https://'). config('app.bucket_name') . '.' . config('app.bucket_domain') . '/' . config('app.bucket_container') . $filepath);
}

}
8 changes: 4 additions & 4 deletions app/Models/Organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function regions()

public function getAttributionFilePath()
{
return '/attribution_images/' . $this->attribution_file_name;
return '/' . $this->attribution_file_name;
}

public function getAttributionImageUrl()
Expand All @@ -54,10 +54,10 @@ public function getAttributionImageUrl()
if (app()->environment('production')) {

//return valid url
return url(config('app.cdn_host') . config('app.cdn_asset_path') . $filepath);
return url(('https://'). config('app.bucket_name') . '.' . config('app.bucket_domain') . '/' . config('app.bucket_container') . $filepath);
}

return url(config('app.url') . config('app.cdn_asset_path') . $filepath);
//TODO configure for QA environment
return url(('https://'). config('app.bucket_name') . '.' . config('app.bucket_domain') . '/' . config('app.bucket_container') . $filepath);
}
}

32 changes: 32 additions & 0 deletions app/Providers/AzureStorageServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;

class AzureStorageServiceProvider extends ServiceProvider
{
public function boot()
{
\Storage::extend('azure', function($app, $config) {
// Usar BlobRestProxy para crear el cliente de Blob Storage
$client = BlobRestProxy::createBlobService($config['connection_string']);

// Crear el adaptador para Azure Blob Storage
$adapter = new AzureBlobStorageAdapter(
$client,
$config['container']
);

return new Filesystem($adapter);
});
}

public function register()
{
//
}
}
Empty file modified bootstrap/cache/.gitignore
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
"laravel/vapor-ui": "^1.6",
"league/csv": "^9.8",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-azure": "^1.0",
"league/flysystem-azure-blob-storage": "^0.1.4",
"league/fractal": "^0.20.0",
"maxbanton/cwh": "^2.0",
"microsoft/azure-storage-blob": "^1.0",
"psr/log": "1.1.4"
},
"require-dev": {
Expand Down
Loading
Loading