使用.Net MinIO SDK 踩的坑


1、連接客戶端時報錯:MinIO API responded with message=No path allowed in endpoint 

1
2
3
4
MinioClient minioClient =  new  MinioClient( "http://XXXX:9000" ,
                                           accessKey: "Q3AM3UQ867SPQQA43P2F" ,
                                           secretKey: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
                                           ).WithSSL();

  

解決方法:把url的前綴http://去掉即可

2、報錯MinIO API responded with message=Connection error: The SSL connection could not be established, see inner exception. The handshake failed due to an unexpected packet format.. Status code=0, response=The SSL connection could not be established, see inner exception. The handshake failed due to an unexpected packet format., content=)'

沒有搭https的話,把連接語句的 WithSSL() 去掉即可

3、有個需求是從FTP服務里下載文件然后上傳到MInIO,FTP使用了FluentFTP SDK,下載文件時直接new一個MempryStream來存儲ftp文件的流,這樣會導致上傳到Minio的時候獲取不到真正的文件size。

1
2
3
4
var  stream =  new  MemoryStream()
await ftpClient.DownloadAsync(stream, item.FullName);
 
await minioClient.PutObjectAsync( "detection" , item.Name, stream, stream.Length,  "image/jpeg" );

所以只能先獲取字節數據,再轉換成流,我也搞不懂為什么,基礎知識太差了。。有大神知道的話麻煩回復一下

1
2
3
4
5
var  byts= await ftpClient.DownloadAsync(item.FullName,0)
using  (MemoryStream br =  new  MemoryStream(byts)) //初始化MemoryStream,並將Buffer指向FileStream的讀取結果數組
{
    await minioClient.PutObjectAsync( "detection" , item.Name, br, br.Length,  "image/jpeg" );
}

 

之后成功上傳到Minio


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM