【发布时间】:2021-06-14 14:53:16
【问题描述】:
我正在尝试使用他们的 API 以及 Laravel 和 Guzzle 将图像上传到 Strapi CMS。每当我发出 POST 请求时,简单的数据,如名称、描述等,都会被完美地发布,只有图像没有。甚至没有任何需要采取行动的错误,只有“200 次成功”。
我做错了吗?
这是我尝试过的: 到目前为止我的处理程序:
$this->processStrapiProductCategory([
'multipart' => [
[
'name' => 'ImageCover',
'contents' => fopen('storage/app/' . $sliderImageInternalUrl, 'r' ),
],
],
'json' => [
'TextCover' => $sliderText,
'Description' => $categoryDescription,
'Name' => $categoryName,
'Slug' => $categorySlug,
],
]);
然后大吃一惊:
private function processStrapiProductCategory($options): void
{
$client = new \GuzzleHttp\Client(['verify' => false]);
try {
$response = $client->request('POST', '192.168.1.109:1337/product-categories/', $options);
dump('StatusCode of guzzle request: ' . $response->getStatusCode());
} catch (\Exception $e) {
dump('Guzzle error: ' . $e->getMessage());
}
}
【问题讨论】:
-
你解决了吗?
标签: php laravel content-management-system guzzle strapi