php - 使用 Guzzle 客户端 API 和 Ajax 在 laravel 中上传多个图像和视频
问题描述
这是我的控制器,它获取访问令牌并发送 URL 以及数据以调用 API 并将图像存储在那里,发送基本 URL 并使用 guzzle 客户端存储 API URL,然后将表单中的所有字段作为参数和发送它们,但在我的第二个微服务中,当我记录请求时,我没有得到任何内容。
public function storeImage(Request $request) {
Log::info('In GalleryController->StoeImage()');
$input = $request->all();
try {
Log::info('Calling GalleryController::getGalleryAccessToken()');
$access_token = $this->getGalleryAccessToken();
Log::info('Got the access token from ProfessionalCategoryController::getProfessionAccessToken(). Now creating Profession!');
Log::info('GALLERY_MANAGEMENT_BASE_URL . GALLERY_STORE_IMAGE__URL: ' . Config::get('app.GALLERY_MANAGEMENT_BASE_URL') . Config::get('app.GALLERY_STORE_IMAGE__URL'));
$http = new Client(); //GuzzleHttp\Client
$response = $http->post(
Config::get('app.GALLERY_MANAGEMENT_BASE_URL') . Config::get('app.GALLERY_STORE_IMAGE__URL'),
[
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $access_token
],
'form_params' => $request->all()
]
);
Log::info('Got the response from Store Image');
$responseJson = json_decode($response->getBody()->getContents(), true);
return response()->json($responseJson, 200);
} catch (\Exception $e) {
Log::info('There was some exception inProfessionalCategoryController->createProfession()');
Log::info($e->getMessage());
$response = [
'success' => false,
'data' => '' ,
'message' => $e->getMessage()
];
return response()->json($response, 500);
}
}
解决方案
推荐阅读
- python - 有没有人遇到过这个错误?如何调试它?
- java - Java RecycleView 在不同页面中加载图像
- haskell - 通过模式匹配创建一个简单的 cli 参数解析器
- c - 我在 Linux 内核中找不到 proc_create_data 函数的定义 - 或者我找到了但没能理解
- vue.js - 有没有办法将 VueJS 模板字符串转换为 createElement 语法
- perl - 如何在 perl-5.32.0 上安装 Method::Signatures?
- javascript - 我如何在 For 循环中使用 Promises
- docker - 如何让 jenkins 容器创建的 SQL Server 容器能够查看主机的 .bak 文件?
- python - 数据框:比较组内的值
- reactjs - 自定义 React Hook 不适用于 Rollup