Skip to content

add solution#210

Open
KuzmenkoGit wants to merge 3 commits intomate-academy:masterfrom
KuzmenkoGit:develop
Open

add solution#210
KuzmenkoGit wants to merge 3 commits intomate-academy:masterfrom
KuzmenkoGit:develop

Conversation

@KuzmenkoGit
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great work on setting up the server and the HTML form! The client-side implementation is excellent. However, I'm requesting a couple of changes to the server-side logic to meet all the requirements.

There are two main issues in src/createServer.js that need to be addressed:

  1. Incorrect File Extensions: The server is appending the full compression type name to the file (e.g., file.txt.gzip). The requirements specify using .gz for gzip and .dfl for deflate. You'll need to map the compressionType from the form to these specific extensions.

  2. Buffering File in Memory: The current code collects all data chunks and creates a single buffer, which loads the entire file into memory. This undermines the requirement to use streams for handling large files efficiently. To fix this, you should process the incoming request stream chunk by chunk, piping it through the appropriate zlib transform stream and then to the response.

Once these two issues are resolved, your solution will be in great shape. Keep up the good work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +34 to +37
req.on('data', (chunk) => chunks.push(chunk));

req.on('end', () => {
const buffer = Buffer.concat(chunks);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While this approach works for small files, collecting all chunks in an array and creating a single buffer loads the entire file into memory. This defeats the purpose of using streams for handling potentially large file uploads. A more robust solution would process the incoming request stream (req) chunk by chunk, parsing the multipart/form-data as it arrives.


res.setHeader(
'Content-Disposition',
`attachment; filename=${originalFilename}.${compressionType}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task requirements specify the extensions should be .gz for gzip and .dfl for deflate. Currently, you are appending the full compression type name (.gzip, .deflate). You should map the compressionType to the correct file extension.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great work on implementing the streaming parser! That's a major improvement and addresses the most significant feedback from the last review.

This is very close to complete, but one change is needed. The server is currently creating filenames with extensions like .gzip and .deflate. According to the requirements, these should be abbreviated to .gz and .dfl respectively. Please adjust the logic in src/createServer.js to map the compressionType to the correct file extension when setting the Content-Disposition header.

Once that's fixed, your solution will be perfect. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +136 to +138
res.setHeader(
'Content-Disposition',
`attachment; filename=${filename}.${compressionType}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The Content-Disposition header is using the compressionType variable directly, which results in file extensions like .gzip and .deflate. According to the task requirements, the extensions should be .gz for gzip and .dfl for deflate.

You'll need to map the compressionType value to the correct file extension before constructing the filename.

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.

2 participants