如何将带有“ -i --upload-file”的curl调用转换为Java Unirest或任何其他http请求?

如何将带有“ -i --upload-file”的curl调用转换为Java Unirest或任何其他http请求?,第1张

如何将带有“ -i --upload-file”的curl调用转换为Java Unirest或任何其他http请求

下面的方法将图像上传到linkedIn

参考:https : //docs.microsoft.com/zh-
cn/linkedin/marketing/integrations/community-management/shares/vector-asset-
api#upload-the-image

private void uploadMedia(String uploadUrl,String accessToken) throws IOException {RestTemplate restTemplate = new RestTemplate();HttpHeaders headers = new HttpHeaders();headers.add("Authorization","Bearer "+accessToken);byte[] fileContents = Files.readAllBytes(new File("path_to_local_file").toPath());HttpEntity<byte[]> entity = new HttpEntity<>(fileContents, headers);restTemplate.exchange(uploadUrl,HttpMethod.PUT, entity, String.class);      }


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5429418.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-11
下一篇2022-12-11

发表评论

登录后才能评论

评论列表(0条)

    保存