Quantcast
Channel: Questions in topic: "webgl"
Viewing all articles
Browse latest Browse all 2390

WebGL System.IO.StreamReader error

$
0
0
Hello, I'm trying to use this S3 method to simply get a file from S3 bucket: public void GetObject(string fileName, string folderName, string downloadPath, object scriptable = null, string bucketNameS3 = "XXXX") { string bucketFilePath = folderName.Length > 0 ? folderName + fileName : fileName; Debug.Log(string.Format("fetching {0} from bucket {1}", bucketFilePath, bucketNameS3)); S3Client.GetObjectAsync(bucketNameS3, bucketFilePath, (responseObj) => { byte[] data = null; var response = responseObj.Response; if (response.ResponseStream != null) { using (StreamReader reader = new StreamReader(response.ResponseStream)) { using (MemoryStream memory = new MemoryStream()) { var buffer = new byte[4096]; var bytesRead = default(int); while ((bytesRead = reader.BaseStream.Read(buffer, 0, buffer.Length)) > 0) { memory.Write(buffer, 0, bytesRead); } data = memory.ToArray(); Debug.Log("Data to array"); if (OnComplete != null) { OnComplete(downloadPath + fileName, data, scriptable); } } } } }); } The callback then simply write the data: File.WriteAllBytes(Application.streamingAssetsPath, data) Everything works fine in my desktop build but when i try to execute the same in webgl, i get the following error: ArgumentNullException: Value cannot be null. Parameter name: stream at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean leaveOpen) [0x00000] in <00000000000000000000000000000000>:0 If you want to take a look, you can visit the application here and take a look to the console. https://wakitowaki.github.io/blablabla/index.html I really can not understand why. Can somebody help me figuring out what's goin on? M.

Viewing all articles
Browse latest Browse all 2390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>