Skip to content

Decrypting a file to output buffer fails #182

@Nathan-Furnal

Description

@Nathan-Furnal

Hi, I'm creating an application where files are encrypted when they're received and decrypted only when an authenticated user clicks on the file link in their own dashboard. As such, I'm trying to write to the output buffer so it's downloaded on their end but never appears decrypted on the server's storage.

To do this I do something like the following in a function body, that function is called with a POST request that fetches the $file name and id in storage. I got the writing to output lines from this pull request.

$filepath = storage_path().'/app/'.$file->name;
$stream = fopen('php://output', 'wb');
ob_start();
File::decrypt($filepath, $stream, $enc_key);

But when I use is, I get a type error:

ParagonIE\Halite\File::decrypt(): Argument #2 ($output) must be of type ParagonIE\Halite\Stream\MutableFile|string, 
resource given

How can I fix this?

Sorry if this seems trivial, I'm not used to web dev at all.

This is all running inside a VM using Homestead ("laravel/homestead": "^13.2") with the most recent version of Halite as well.

PHP: 8.1.3
Laravel Framework 9.23.0
Homestead: 13.2.1
Halite: 5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions