'How to get the filename from context in Grapevine?

how to get the filename from context to enter instead of "something.png", in this code:

(https://github.com/scottoffen/grapevine-legacy/issues/124)

[RestResource(BasePath = "/file")]
public class FileModule
{
    private const int ChunkSize = 1024;

    [RestRoute(HttpMethod = HttpMethod.POST, PathInfo = "/upload")]
    public IHttpContext UploadBinaryFile(IHttpContext context)
    {
        if (!context.Request.HasEntityBody)
        {
            context.Response.SendResponse(HttpStatusCode.InternalServerError, "Data not received");
            return context;
        }

        // If you access context.Request.Payload here, you will 
        // get a string representation of the binary data and
        // Advanced.InputStream will return nothing in the next
        // section.

        using (var input = ((HttpRequest)context.Request).Advanced.InputStream)
        {
            using (var reader = new BinaryReader(input, context.Request.ContentEncoding))
            {
                using (var output = new BinaryWriter(File.Open("something.png", FileMode.Create)))
                {
                    var chunk = reader.ReadBytes(ChunkSize);
                    while (chunk.Length > 0)
                    {
                        output.Write(chunk);
                        chunk = reader.ReadBytes(ChunkSize);
                    }
                }
            }
        }

        // If you access context.Request.Payload here, you will get an empty string

        context.Response.SendResponse(HttpStatusCode.Ok);
        return context;
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source