#305-fileService PR 2.0 #947

Merged
a22erigr merged 17 commits from #305-fileService into team_2_week_6 2026-05-15 12:32:40 +00:00
Collaborator

fileService

Created a service to upload and download files to.

Endpoints

Endpoint Description Request body
GET /f/{id} Fetch a file None
POST /upload/ Upload a file Multipart/form-data

Testing

I recommend rebuilding everything before testing.
For testing the /api/files/upload/ endpoint you can either use an HTML file:

<!DOCTYPE html>
<html lang="en">
<body>
    <form action="http://localhost/api/files/upload/" method="post" enctype="multipart/form-data">
        <input type="file" name="image" id="image">
        <button type="submit">Upload</button>
    </form>
</body>
</html>

Or you can use Bruno. In order to use bruno, you must send the upload as a POST request, with the MIME/media type being "multipart/form-data". The image should be sent in the Key/Value field with the key name being "image". Here you can see an example:
image

In order to view your uploaded file, you use the /api/files/f/{id} endpoint, with the id being the "name" field of the response you get when you upload. Here is what that looks like in a browser:
image
And in bruno:
image
Note that in bruno, you must enter the id as a path variable by typing /api/files/f/:id in the url, and then entering the value in the table for path variables. See the example above.

# fileService Created a service to upload and download files to. ## Endpoints | Endpoint | Description | Request body | |---|---|---| | `GET /f/{id}` | Fetch a file | None | | `POST /upload/` | Upload a file | Multipart/form-data | ## Testing I recommend rebuilding everything before testing. For testing the `/api/files/upload/` endpoint you can either use an HTML file: ```HTML <!DOCTYPE html> <html lang="en"> <body> <form action="http://localhost/api/files/upload/" method="post" enctype="multipart/form-data"> <input type="file" name="image" id="image"> <button type="submit">Upload</button> </form> </body> </html> ``` Or you can use Bruno. In order to use bruno, you must send the upload as a POST request, with the MIME/media type being "multipart/form-data". The image should be sent in the Key/Value field with the key name being "image". Here you can see an example: ![image](/attachments/6e10817d-0d28-494c-be26-8ab1242cd5f7) In order to view your uploaded file, you use the `/api/files/f/{id}` endpoint, with the id being the "name" field of the response you get when you upload. Here is what that looks like in a browser: ![image](/attachments/849d5314-f729-47cd-8b12-ffd561b1ad6a) And in bruno: ![image](/attachments/e34765f4-b93e-4a11-9209-bdb32f882717) Note that in bruno, you must enter the id as a path variable by typing `/api/files/f/:id` in the url, and then entering the value in the table for path variables. See the example above.
Ripped straight from tempService.
Nothing done at this point. will get worked on.
The API endpoints now run, but they don't return images or allow for uploading yet. I've implemented some file validation for the upload to make sure that the files uploaded isn't an exe masquerading as an image file. There is also some debugging code in there but it's commented as such for easy removal. There are improvements to be made
lots of code (unreadable)
This reverts commit 6e81f26bcd.
a24julot changed target branch from Temp-Main-Week-5 to team_2_week_6 2026-05-13 13:55:29 +00:00
b24idalu requested changes 2026-05-13 16:03:56 +00:00
Dismissed
b24idalu left a comment
Collaborator

Review on #305

Whats done

Implemented a file system.

Tested on Windows using Bruno

  • App starts
    • App works well.
    • Tested endpoints through Bruno, works well and does what is intended.

Inspected following files.

  • DockerCompose/init_sql/04-files.sql
    • Naming convention
      • Looks good except for the variable name "file_contenttype" which should probably be "file_content_type"
  • service/fileService/fileService.Test/UnitTest1.cs & service/fileService/fileService.Test/fileService.Test.csproj
    • Code quality
      • There is a blankspace at the start of both files, unsure if we can remove those.
  • service/fileService/fileService/Services/FileService.cs
    • Comments
      • On line 113 there is a comment that has, from what I assume, unnecessary text ("idk dawg")
  • Rest of the files look awesome.

What needs to be done

  • The above files should be fixed

Conclusion

  • It is ready to merge after fixing the comments
  • Should we create a folder for Bruno stuff? Easier to test endpoints and document
# Review on #305 ## Whats done Implemented a file system. ### Tested on Windows using Bruno + App starts + App works well. + Tested endpoints through Bruno, works well and does what is intended. ### Inspected following files. + DockerCompose/init_sql/04-files.sql + Naming convention + Looks good except for the variable name "file_contenttype" which should probably be "file_content_type" + service/fileService/fileService.Test/UnitTest1.cs & service/fileService/fileService.Test/fileService.Test.csproj + Code quality + There is a blankspace at the start of both files, unsure if we can remove those. + service/fileService/fileService/Services/FileService.cs + Comments + On line 113 there is a comment that has, from what I assume, unnecessary text ("idk dawg") + Rest of the files look awesome. ## What needs to be done + The above files should be fixed ## Conclusion + It is ready to merge after fixing the comments + Should we create a folder for Bruno stuff? Easier to test endpoints and document
Author
Collaborator

I've removed the comment. I think i misunderstood what you meant by with the blankspace in UnitTest1.cs and fileService.Test.csproj but I removed a blank line in one of them. I'm couldn't find a way to remove the [U+FEFF] so I think we might have to live with it. I also changed file_contenttype to file_content_type in the database and the DatabaseQueries file.

I've removed the comment. I think i misunderstood what you meant by with the blankspace in UnitTest1.cs and fileService.Test.csproj but I removed a blank line in one of them. I'm couldn't find a way to remove the [U+FEFF] so I think we might have to live with it. I also changed file_contenttype to file_content_type in the database and the DatabaseQueries file.
b24idalu approved these changes 2026-05-15 12:13:46 +00:00
b24idalu left a comment
Collaborator

Looks good!

Looks good!
a22erigr merged commit d1f8a47358 into team_2_week_6 2026-05-15 12:32:40 +00:00
c24danli deleted branch #305-fileService 2026-05-21 12:42:53 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Andras/BoundlessFlowCampus2K!947
No description provided.