Apache Flink Rest-Client Jar-Upload无法正常工作 [英] Apache Flink Rest-Client Jar-Upload not working

查看:646
本文介绍了Apache Flink Rest-Client Jar-Upload无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力通过使用Flink rest-api(可以在

I am struggling to automatically deploy new Flink jobs within our CI/CD workflows by using the Flink rest-api (which may be found here in the flink Github repository).

文档仅说明可以使用/jars/upload来实现jar上传,但不能确定必须如何构建有效的rest请求(哪个Headers,哪个Body类型,哪个Authorization,哪个Method等).

Documentation only says that that jar upload may be achieved by using /jars/upload, but not how exactly a valid rest request has to be build (which Headers, which Body type, which Authorization, which Method and so on).

因此,我查看了Github上flink/flink-runtime-web项目的Flink仪表板代码,并搜索了

So I took a look at the Flink dashboard code of flink/flink-runtime-web project on Github and searched for the implementation they used to upload a jar and - Yippie! Its implemented by calling the rest-api I am trying to use (using POST as method). After that I tried to figure out with Postman which is correct way to send requests using different Content-Type headers and Body types, but none of them worked for me now.

我本来可以直接向flink项目提交票证,但是找不到任何有关其票证系统的引用.

I would have filed a ticket directly to the flink project, but could not find any reference to their ticket system.

所以这里的基本问题是:

  • 如何成功调用其余端点/jars/upload才能成功上传文件?
  • How do I have to call the rest endpoint /jars/upload to successfully upload a file?

推荐答案

我遇到了同样的问题,并在通过Web UI上传jar时通过查看chrome中的网络请求解决了该问题.

I've run into the same issue and solved it by looking at the network request in chrome when uploading a jar with the web UI.

请求必须

  • 使用分段上传
  • 字段名称必须为jarfile
  • 多部分内容必须还包括文件Content-Type(否则,您会因抱怨缺少标题而从Flink收到500)
  • Use multipart upload
  • The field name must be jarfile
  • The multi part content must include the file Content-Type as well (otherwise you'll get a 500 from Flink complaining about the missing header)

这是一个使用请求进行上传的python脚本

Here is a python script using requests that does the upload

upload = requests.post(                                                                                               
    base_url + "/jars/upload",                                                                                        
    files={
        "jarfile": (
            os.path.basename(path), 
            open(path, "rb"), 
            "application/x-java-archive"
         )
    }
)       

这篇关于Apache Flink Rest-Client Jar-Upload无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆