Bird
0
0

Which of the following is the correct syntax to stream a file from a Remix loader using a Response object?

easy📝 Syntax Q3 of 15
Remix - Advanced Patterns
Which of the following is the correct syntax to stream a file from a Remix loader using a Response object?
Areturn fetch(fileStream, { headers: { 'Content-Type': 'image/png' } })
Breturn new Response(fileStream, { headers: { 'Content-Type': 'image/png' } })
Creturn Response.send(fileStream, { type: 'image/png' })
Dreturn new Response({ body: fileStream, contentType: 'image/png' })
Step-by-Step Solution
Solution:
  1. Step 1: Understand Response constructor

    In Remix, streaming a file uses the standard Web Response constructor with a stream as the body and headers for content type.
  2. Step 2: Correct syntax for streaming

    The correct syntax is new Response(fileStream, { headers: { 'Content-Type': 'image/png' } }).
  3. Final Answer:

    return new Response(fileStream, { headers: { 'Content-Type': 'image/png' } }) -> Option B
  4. Quick Check:

    Stream file with new Response and headers = C [OK]
Quick Trick: Use new Response(stream, { headers }) to stream files [OK]
Common Mistakes:
MISTAKES
  • Using Response.send which does not exist
  • Passing stream incorrectly as fetch argument
  • Misplacing content type in options

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes