i have a wierd problem i cant seem to get around.
I have a gzip file that i can upload to my Firebase Storage bucket easily using the gsutil tool:
gsutil -h "Content-Encoding:gzip" -h "Content-Type:application/json" cp myGzipFileWithoutGzExtension.json gs://my-bucket-name.appspot.com
The file starts as a normal json file, compressed its 32kb.
Now i want to do the same in my c# console app. But when i upload to the same url, Firebase Storage removes compression and the file ends up around 400kb (removed whitespaces etc) ?!?!
var url = "https://firebasestorage.googleapis.com/v0/b/my-bucket-name.appspot.com/o?name=myGzipFileWithoutGzExtension.json"
var stream = File.Open(@"C:\temp\myGzipFileWithoutGzExtension.json ", FileMode.Open);
using (var client = new HttpClient())
{
var streamContent = new StreamContent(stream);
streamContent.Headers.Add("Content-Encoding", "gzip");
streamContent.Headers.Add("Content-Type", "application/json");
streamContent.Headers.ContentLength = stream.Length;
var request = new HttpRequestMessage(HttpMethod.Post, url)
{
Content = streamContent,
};
var response = await client.SendAsync(request, cancellationToken).ConfigureAwait(false);
var responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
}
Am i going about the wrong way doing this? I just want to upload my 32kb json (gzip) file, and have the correct Content-Encoding on it so that the browser will handle the decompression (works when i do it with the gsutil uploaded file, so its working as expected)