Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

[Feature Request] Support for setting metadata on file upload, and downloading it along with file contents. #125

Open
OJezu opened this issue Dec 10, 2019 · 3 comments

Comments

@OJezu
Copy link
Contributor

OJezu commented Dec 10, 2019

I would like to add support for setting metadata, like Content-Type (as third argument to put), and include the file metadata along the file content in response from get* methods (Azure returns it anyway, I suspect other storage providers do that too).

I need that in my application, so that our thumbnail service can properly recognize file formats. There are also some security implications if Content-Type of uploaded file must be ignored (as is always set to default value).

I propose adding third argument to put: put(location: string, content: Buffer | Readable | string, metadata?: FileMetadata) and extending ContentResponse to:

export interface ContentResponse<ContentType> extends Response {
	content: ContentType;
        metadata: FileMetadata;
}

Possibly also aliasing StatResponse to FileMetadata?

@RomainLanz
Copy link
Member

Hey @OJezu! 👋

Could you please provide a real world example of this use-case?

I cannot really get why it would be useful.

@OJezu
Copy link
Contributor Author

OJezu commented May 20, 2020

@RomainLanz

  • Setting the Content-Type for proper delivery from the cloud to other clients. Example with the thumbnail service given above.
  • Adding versioning or owner info to the stored file using metadata mechanisms available for all cloud storages.
  • Avoiding potential security issues, if attacker uploads a executable file, where an image is expected, and then it is stored in cloud with wrong Content-Type (default application/octet-stream instead of image/*).
  • This is a feature of all cloud storages, deemed needed or useful by all cloud product teams.

@zamarawka
Copy link

@RomainLanz I stuck with wrong content-type too. May be I miss something, but I upload data to aws s3 by this code
disk.put(storagePath, fs.createReadStream(file.path)). As result I get on s3 content-type: 'application/octet-stream', so i couldn't deliver these files from s3 by s3-website.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants