mevdschee / mevdschee/php-crud-api

Returning user uploaded file using custom controller

Open
#1,029 2 comments 1 reaction 1 assignee View on GitHub

@mevdschee is already working on this.

Since Apr 2, 2024.

help wanted
Dominant language
PHP
Stars
3.7k
Forks
1k
Avg merge
1h 55m
Merged PRs (30d)
7

Description

Hi everybody.

I made a custom controller to handle file uploads and I'd like to add the capability to return the file via API made using this repository.
In the function __construct function I added:

$router->register('GET', '/records/file/*', array($this, 'getFileV2'));

In

public function getFileV2(ServerRequestInterface $request): ResponseInterface

I need to get the file, decrypt (because in POST controller function the file is correctly uploaded as encrypted) but also if I add

header("Content-Type: image/png");
return $decryptedFile;

I can't view the file and the error message is:

UploadUserFile::getFileV2(): Return value must be of type Psr\\Http\\Message\\ResponseInterface, string returned

How can I do this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.