Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementations for local storage #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ bower_components
.php_cs.cache
storage/debugbar/
public/build/
storage/
2 changes: 1 addition & 1 deletion app/Http/Controllers/DocumentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function upload(Request $request, $external_id)
session()->flash('flash_message_warning', __('You do not have permission to upload a document'));
return redirect()->route('tasks.show', $external_id);
}
$client = Client::whereExternalId($external_id)->first();
$client = Client::whereExternalId($external_id);

$file = $request->file('file');
$filename = str_random(8) . '_' . $file->getClientOriginalName();
Expand Down
15 changes: 10 additions & 5 deletions app/Services/Storage/Local.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
<?php
namespace App\Services\Storage;

use App\Models\Document;
use App\Repositories\FilesystemIntegration\FilesystemIntegration;
use Illuminate\Support\Facades\Storage;

class Local implements FilesystemIntegration
{
public function isEnabled()
{
return false;
return true;
}

public function upload($client_folder, $filename, $file): array
{
return [];
Storage::disk('local')->put($client_folder, $file);

return ['file_path' => $client_folder . '/' . $file->hashName()];
}

public function delete($full_path): bool
{
return true;
return Storage::disk('local')->delete($full_path);
}

public function view($file)
{
// TODO: Implement view() method.
return $this->download($file);
}

public function download($file)
{
// TODO: Implement download() method.
$fileData = Storage::disk('local')->get($file->path);
return $fileData;
}

public function revokeAccess()
Expand Down