如何解决Laravel 8 http::attach -> 需要“内容”键
$response = Http::attach('InputFile0',file_get_contents('test.docx'),'test.docx')->withHeaders([
'Authorization' => 'Bearer XYZ','X-API-Key' => 'ABC123','Content-Type' => 'multipart/form-data',])->post('https://cpf-ue1.adobe.io/ops/:create',$data);
我得到了回应:
InvalidArgumentException
A 'contents' key is required
文件存在且可读。用
测试dd(file_get_contents('test.docx'));
我也试过
$file = fopen('test.docx','r');
但得到同样的错误,虽然当我转储时我看到了一个流:
stream resource @433 ▼
timed_out: false
blocked: true
eof: false
wrapper_type: "plainfile"
stream_type: "STDIO"
mode: "r"
unread_bytes: 0
seekable: true
uri: "test.docx"
options: []
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。