79699190

Date: 2025-07-12 10:25:47
Score: 1
Natty:
Report link

In the first snippet, the name used in the reference (request) is not the same as the name of the parameter (req), resulting in the undefined symbol 'request' error.

Once the name is fixed and the http:Caller parameter is removed (since you are directly returning the response payload from the resource rather than using the caller value to respond), it should work as expected.

    resource function post upload(http:Request req) returns string|error? {
        stream<byte[], io:Error?> streamer = check req.getByteStream();

        check io:fileWriteBlocksFromStream("./uploads/ReceivedFile.pdf", streamer);
        check streamer.close();
        return "File Received!";
    }

If the erroneous code was from the official documentation, could you report an issue here?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
Posted by: MaryamZi