Home>

When you click on the button, a GET request is made to the server throughhttpwebrequest, the received response is written to the stream:

HttpWebRequest request= (HttpWebRequest) WebRequest.Create ($ "https://kassensichv-middleware.fiskaly.com/api/v2/tss/3f5bdf20-3050-4a7e-b316-e23edf645bdb8export/1b 0a16-4592-a246-7db897c73196 /file ");
request.Method= "GET";
request.ContentType= "application /x-tar";
request.Timeout= 10 * 1000;
request.Headers.Add (HttpRequestHeader.Authorization, $ "Bearer {response.AccessToken}");
using (var resp= (HttpWebResponse) request.GetResponse ())
using (var streamReader= new StreamReader (resp.GetResponseStream () ?? throw new InvalidOperationException ()))
{
    var result= streamReader.ReadToEnd ();
}

Tell me what you need to do next to write it downResponse?

When used:

byte [] compressedArray= Encoding.GetEncoding (1252) .GetBytes (result);
using (MemoryStream ms= new MemoryStream (compressedArray))
{
    using (DeflateStream zip= new DeflateStream (ms, CompressionMode.Decompress))
    {
        MemoryStream byteStream= new MemoryStream ();
        zip.CopyTo (byteStream);
        Response.BinaryWrite (byteStream.ToArray ());
    }
}
Response.End ();

an error occurs.

Do not use WebRequest -it is deprecated and will soon be removed from the framework altogether. Use HttpClient instead.

Alexander Petrov2021-10-15 10:00:01

What error occurs? Always describe the problem accurately!

Alexander Petrov2021-10-15 10:00:27

How to send the archive correctly when you click on the button? just like any other file. But I would not use a server backend to send the file, but rather use a web server to do this. You can allocate a separate directory for temporary files (or even CDN), make a handler for obsolete files so that old ones are deleted. When a request is received, save the archive to a special directory, after which, in response to the client, send a 302 redirect to it. As a result, the server backend will not be loaded with file distribution.

aepot2021-10-15 10:58:55