caozhiyuan / FastDFSNetCore

FastDFS Async Client
Apache License 2.0
65 stars 23 forks source link

上传一个41字节的文本文件,下载回来是256字节? #13

Closed andy65007 closed 5 years ago

andy65007 commented 5 years ago

调用库后,改变了原有文件内容,不太好啊

caozhiyuan commented 5 years ago

你可以手动调fastdfsclient 上传试下

andy65007 commented 5 years ago

手动调?啥意思?

andy65007 commented 5 years ago

下面代码有问题吗? `List pEndPoints = new List() { new IPEndPoint(IPAddress.Parse("192.168.80.5"), 22122) }; ConnectionManager.Initialize(pEndPoints);

string fileName = "test.txt"; string path = Path.Combine("D:\", fileName);

StorageNode node = FastDFSClient.GetStorageNodeAsync().GetAwaiter().GetResult(); string s = FastDFSClient.UploadFileAsync(node, new MemoryStream(File.ReadAllBytes(path)), "txt").GetAwaiter().GetResult();;

Console.WriteLine(s);

byte[] fileData = FastDFSClient.DownloadFileAsync(node, s).GetAwaiter().GetResult(); Console.WriteLine("length:" + fileData.Length);

File.WriteAllBytes("D:\123.txt", fileData);

        `
caozhiyuan commented 5 years ago

please use

Task DownloadFileAsync(StorageNode storageNode, string fileName,
            IDownloadCallback downloadCallback,
            long offset = 0,
            long length = 0)

i will fix return byte array bug

caozhiyuan commented 5 years ago

@andy65007 fixed in 1.2.4 , suggest use stream for big file.

andy65007 commented 5 years ago

good!