All Products
Search
Document Center

Object Storage Service:What do I do if the size of an object uploaded to OSS by using MemoryStream of OSS SDK for .NET is displayed as zero?

Last Updated:Dec 22, 2024

Problem description

In use.When the Apsara Stack Network Operations Platform SDK uploads a file through the MemoryStream method, because the current position of the MemoryStream default file pointer is the tail of the stream, the file can be uploaded successfully, but the size of the file is 0.

cf3019dfc6222f43187618348bb325d7

Solutions

  1. Before uploading the file, use the mStream.Seek(0, SeekOrigin.Begin); to zero the file pointer. The code example is shown in the following figure. p512301

  2. Confirm that when you use the MemoryStream method to upload an object, the object size can be displayed.

    27d307ae4663f3a034c4d7b84a9354ca