Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom filename on upload #8

Closed
manekinekko opened this issue Aug 14, 2019 · 1 comment

Comments

@manekinekko
Copy link
Collaborator

commented Aug 14, 2019

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When uploading a file to Storage, we use the original filename.

Expected behavior

When uploading a file to Storage, we can provide a custom filename.

What is the motivation / use case for changing the behavior?

Users might want to have a custom logic when it comes to filename, or an internal pattern naming convention...etc

Notes

We should easily change this line so it can accept an external filename https://github.com/nestjs/azure-storage/blob/master/lib/azure-storage.service.ts#L116

@manekinekko

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 14, 2019

It turns out that we can already do this with the current implementation, here is how:

 @Post('azure/upload')
 @UseInterceptors(FileInterceptor('file'))
 async UploadedFilesUsingService(
   @UploadedFile()
   file: UploadedFileMetadata,
 ) {
   file = {
     ...file,
     originalname: 'foo-bar.txt',
   };
   const storageUrl = await this.azureStorage.upload(file, {
     containerName: 'nest-demo-container-service',
   });
   Logger.log(`Storage URL: ${storageUrl}`, 'AppController');
 }```

I will add this to the readme.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.