Nuget 安装包 Hadoop.WebHdfs.Client
以下代码仅仅在 dfs.permissions.enabled = false 的情况下做了简单测试,仅作为备忘录。
上传文件代码
public void UploadFileTest()
{
string srcPath = @"D:\素材\logo\linux.jpg";
string destPath = "/TestPhoto/linux.jpg";
//连接到hadoop集群
WebHdfs.Client.WebHdfsClient client = new WebHdfs.Client.WebHdfsClient("http://192.168.xx.xxx:50070/");
bool res = client.UploadFileAsync(srcPath, destPath).Result;
}
下载文件代码
public void DownFileTest()
{
string srcPath = @"D:\素材\logo\test123.jpg";
string destPath = "/TestPhoto/python.png";
WebHdfs.Client.WebHdfsClient client = new WebHdfs.Client.WebHdfsClient("http://192.168.xx.xxx:50070");
bool res = client.DownloadFileAsync(srcPath, destPath).Result;
}