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

Check for existing file when uploading image #38

Open
jean-michelet opened this issue Oct 21, 2024 · 5 comments
Open

Check for existing file when uploading image #38

jean-michelet opened this issue Oct 21, 2024 · 5 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jean-michelet
Copy link
Contributor

jean-michelet commented Oct 21, 2024

When uploading a task image, we should look if there is already a file associated, and remove it.

@jean-michelet jean-michelet added bug Something isn't working good first issue Good for newcomers labels Oct 21, 2024
@JP-sDEV
Copy link

JP-sDEV commented Oct 21, 2024

Hi can I be assigned this issue?

@jean-michelet
Copy link
Contributor Author

Hi!

Go ahead!

@JP-sDEV
Copy link

JP-sDEV commented Oct 22, 2024

I'm looking through the codebase and correct me if I'm wrong - I suspect that the fastify.post found in demo/src/routes/api/tasks/index.ts is the endpoint to be changed?

@jean-michelet
Copy link
Contributor Author

jean-michelet commented Oct 22, 2024

This is POST /:id/upload.
We store the filename in the tasks table in db for later retrieval.
Look how we do store the file and you will know how to check if there is already an existing file.
When we retrieve a task, we must first look if a file with name = task.filename exists in the upload directory.
But you should delete the file after the db operations.

@JP-sDEV
Copy link

JP-sDEV commented Oct 22, 2024

Understood, I believe I have an idea on where to put the deletion. I'll open a PR hopefully tomorrow morning/afternoon. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants