Apache Flink Rest-Client Jar-Upload 不起作用 [英] Apache Flink Rest-Client Jar-Upload not working

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

问题描述

我正在努力通过使用 Flink rest-api(可以在 此处位于 flink Github 存储库中).

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 上传,但没有说明必须如何构建有效的其余请求(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项目的Flinkdashboard代码,搜索了实现 他们用来上传一个 jar 和 - Yippie!它通过调用我尝试使用的 rest-api 来实现(使用 POST 作为方法).之后,我尝试与 Postman 一起找出使用不同的 Content-Type 标头和 Body 类型发送请求的正确方法,但现在它们都不适合我.

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天全站免登陆