I have been playing about with image uploads and it seems that when I try and use a different type of stream, for example a MemoryStream containing a direct clone of a Stream object (as a result of using Stream.CopyTo(MemoryStream)) the upload appears to succeed but is listed on firebase as an empty file with no metadata. I tried providing the ContentType = "image/jpeg" metadata and this was applied successfully but still an empty, unreadable file was uploaded.
Also when casting between objects of base type System.IO.Stream (MemoryStream, etc....), it doesn't work either.
EG:
MemoryStream memStream = new MemoryStream(byte_data);
reference.PutStreamAsync(memStream);
Doesn't work, neither does:
MemoryStream memStream = new MemoryStream(byte_data);
Stream newStream = (Stream)memStream; // casts correctly (seen when you do newStream.Length)
reference.PutStreamAsync(newStream);
Neither does:
Stream myStream = my_stream_data; // random stream data (my test used the Media Picker functionality from Xamarin.Essentials)
MemoryStream memStream = new MemoryStream();
myStream.CopyTo(memStream); // myStream data is disposed of at this point and no longer accessible
Stream newStream = (Stream)memStream;
reference.PutStreamAsync(newStream);
I have been playing about with image uploads and it seems that when I try and use a different type of stream, for example a
MemoryStream
containing a direct clone of aStream
object (as a result of usingStream.CopyTo(MemoryStream)
) the upload appears to succeed but is listed on firebase as an empty file with no metadata. I tried providing theContentType = "image/jpeg"
metadata and this was applied successfully but still an empty, unreadable file was uploaded.Also when casting between objects of base type
System.IO.Stream
(MemoryStream, etc....), it doesn't work either.EG:
Doesn't work, neither does:
Neither does: