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

feat: file upload (minio, s3, frontend...) #443

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

yoannfleurydev
Copy link
Member

@yoannfleurydev yoannfleurydev commented Jan 12, 2024

Describe your changes

closes #<issue_id>

Simplified version of the Avatar Upload process :
image

Notes :

  • To upload a file in a different folder on the bucket, the path should be included in the key of the file

Left to do / Lines of thought

  •  How do we handle upload of sensitive files (i.e with restricted access) ? Because currently, the files uploaded are public and the url is permanent.
  • How do we keep track (on the server) of the different files uploaded ?
  • Summarize the existing logic for a better understanding
  • There is currently no way of deleting a file from the Frontend
  1. Simplify, clean and remove unused parts to get the existing part working and as simple as possible. (For know, just focus on public file upload for avatars and we'll see later for the rest.
  2. Rebase to get the React-hook-form update
  3. Update the fields

Screenshots

Documentation

Checklist

  • I performed a self review of my code
  • I ensured that everything is written in English
  • I tested the feature or fix on my local environment
  • I ran the pnpm storybook command and everything is working
  • If applicable, I updated the translations for english and french files
    (If you cannot update the french language, just let us know in the PR description)
  • If applicable, I updated the README.md
  • If applicable, I created a PR or an issue on the documentation repository
  • If applicable, I’m sure that my feature or my component is mobile first and available correctly on desktop

Copy link

vercel bot commented Jan 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
start-ui ❌ Failed (Inspect) May 13, 2024 3:05pm

Copy link

sonarcloud bot commented Jan 12, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@ntatoud
Copy link
Contributor

ntatoud commented Apr 8, 2024

TODO :

  • Upload multiple files ??
  • Verify file types => Any file can be uploaded as an avatar
  • Maybe improve README with new modifications ?

@ntatoud
Copy link
Contributor

ntatoud commented May 6, 2024

Here is the idea for the refactor I did in commit : refactor(file-upload): Remove hook abstraction layer and regroup feature's files

image

src/files/utils.ts Outdated Show resolved Hide resolved
src/files/utils.ts Outdated Show resolved Hide resolved
>
) =>
async (
file?: File,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the file is optional ? can we make it required ? (I don't see a use case where we call uploadFile without a file ^^)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to check at one point if the file retrieved from the form is empty or not.
The choice was made to handle the 'file is undefined' case in this function but could be moved in the form, before making the call to the mutation ?

Let me know what you think is best ?

src/server/config/s3.ts Outdated Show resolved Hide resolved
src/features/account/AccountProfileForm.tsx Show resolved Hide resolved
Copy link

sonarcloud bot commented May 13, 2024

Quality Gate Passed Quality Gate passed

Issues
5 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud


// Here we can use '!' on mockFile.name to prevent TS error because we are sure it is defined
const input = screen.getByLabelText<HTMLInputElement>(mockFile.name!);
await user.upload(input, mockFile.file ?? []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder : Remove this line, it was copy pasted from the other test and should not be here

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

Successfully merging this pull request may close these issues.

None yet

5 participants