movepixels's avatar

View encrypted file

I am using this package to upload / encrypt / store uploaded images.

https://github.com/soarecostin/file-vault

Basically user uploads 3 images required which get encrypted into a private folder. That is working fine.

Now admin needs to review these images. So I do not want to download in the browser with the streamDownload function. I do not see any options and looked / googled / on how to simply get that encrypted image, decrypt it and i assume make a base_64 string and return that to the front-end with my API json response.

So question is how can i view these uploaded images?

Using league/flysystem-aws-s3-v3 so I can upload the images right now no problem. They are encrypted, but when i try to get the image:

$file = 'https://some.remote.location/development/verification/3729828c-4d69-11ec-866b-7f65ebec3fd0/0611fdf9-70e4-4b3f-b33c-bc430fa6d48c.jpg.enc';

if (!Storage::disk('spaces')->has($file)) {
     return 'File not found'; // never found yet typed into browser directly forces browser to download the .enc file so its there
}

$image = Storage::disk('spaces')->get($file);

Step I assume => get this file content => decrypt it => remove .enc extension => base_64 encode => set that as the data to return to API response?

I just can not seem to get the first step of getting the file from the spaces folder

Anyone have any ideas?

Thanks again everyone

0 likes
5 replies
movepixels's avatar

@Snapey I am able to test the path and find the file as you noted the path, but still im stuck on how to read that file, decrypt it and return it along with other data in the API json response to the front end for the user.

movepixels's avatar

@Tray2 Thanks for the link, looking thru and reading its to download the uploaded files.

I do not want to click download to view them.

Think of a page where an admin can go to view the users uploaded documents (image files only). He would click approve / reject buttons below each image. Not manually download each then view each individually.

"Why are you encrypting them?" I suppose same could be said why do we hash passwords? Any document of legal value should simply not just be tossed in a folder and said ohh its private thats secure enough. Mr hacker comes along and gains access to your folder and look thousands of files for the viewing vs encrypted files. But thats just my opinion, but thanks for the link and your time all the same :)

movepixels's avatar

I uploaded a private non-encrypted file (jpg) into a private folder

return \Storage::disk('spaces')->has($img) ? base64_encode($file) : 'image not found';

And able to return the data along with other API json in a response and display it on the page. So I know that this is working so far.

So its just figuring out the missing step of decrypting the file, at what point / where / how is this done. Here is the package and options.

https://github.com/soarecostin/file-vault

Please or to participate in this conversation.