Towards managing mapping for file imports.

This commit is contained in:
James Cole
2018-05-06 16:19:29 +02:00
parent 9e3c5fd984
commit a3cbdadb39
11 changed files with 868 additions and 84 deletions

View File

@@ -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
*

View File

@@ -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
*/