将hdfs文件发布/加载到某个URL

时间:2013-01-08 08:39:40

标签: java file-upload hadoop hdfs

我想使用MultipartEntity和HttpPost将hdfs文件发布到url,如何在下面的代码中指定文件/ contentbody

HttpPost httppost = new HttpPost("someurl");
MultipartEntity entity=new MultipartEntity();
entity.addPart("data",new FileBody(file));  // Here i need to specify file or inputstream
httppost.setEntity(entity);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);

我正在使用FileSystem calss

来引用文件
Path filepath=new Path(args[0]);
FileSystem fs=FileSystem.get(new Configuration());
fs.open(filepath)  // returns FSDataInputStream

0 个答案:

没有答案