mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Towards managing mapping for file imports.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace FireflyIII\Helpers\Attachments;
|
||||
|
||||
use Crypt;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
@@ -64,6 +65,24 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
$this->uploadDisk = Storage::disk('upload');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentContent(Attachment $attachment): string
|
||||
{
|
||||
try {
|
||||
$content = Crypt::decrypt($this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)));
|
||||
} catch (DecryptException $e) {
|
||||
Log::error(sprintf('Could not decrypt data of attachment #%d', $attachment->id));
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
|
@@ -39,6 +39,13 @@ interface AttachmentHelperInterface
|
||||
*/
|
||||
public function getAttachmentLocation(Attachment $attachment): string;
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentContent(Attachment $attachment): string;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
|
Reference in New Issue
Block a user