soarecostin / file-vault

A Laravel package for encrypting and decrypting files of any size
MIT License
184 stars 63 forks source link

signed url for a s3 file that will return to api response #28

Open UsamaKhan-hub opened 1 year ago

UsamaKhan-hub commented 1 year ago

Trying to upload enc files on s3 and retrieving them to create a signed url for the response to an API to access them from s3. What i have achieved so far is :

Files are being uploaded to s3 as (.enc) even if i use streamDownload and decrypt file , saves it, it's working perfectly.

1- I am trying to get a singed url for a file that will return to api response , which is i am getting correctly using : $command = $client->getCommand('GetObject', [ 'Bucket' => $bucket, 'Key' => **FileVault::disk('s3')->decrypt($key),** ]); $request = $client->createPresignedRequest($command, '+20 minutes'); $presignedUrl = (string)$request->getUri(); It is working fine if i put path of a normal file to key but when i try to decrypt it as well it says :

"message": "Found 1 error while validating the input provided for the GetObject operation:\n[Key] must be a string or an object that implements __toString(). Found object(SoareCostin\FileVault\FileVault)",

If you could guide me @soarecostin . Bundle of thanks already for this wonderful package.