如何使用 php 显示来自 dreamfactory 的文件夹中的图像
How to display images in files folder from dreamfactory using php
我已将图片文件上传至梦工厂文件夹
<img src="https://motodev.spotya.online/api/v2/files/Posts/posts_1508937621_Tulips.jpg">
显示错误,
{"error":{"code":400,"context":null,"message":"No session token (JWT)
or API Key detected in request.."}
您在 dreamfactory 中的 files
端点似乎已受到保护。您需要提供 API 密钥或 JWT 令牌才能访问此目录中的文件。另一种方法是添加对 files
端点的访客访问,如 here.
所述
您需要像 https://example.org/api/v2/files/image.jpg?api_key=<your api key>
一样生成 url。例如:
<?php
// your guest API key
$apiKey = 'your api key should be here';
// your file URL
$baseUrl = 'https://example.org/api/v2/files/image.jpg';
// resulted URL
$finalUrl = $baseUrl . http_build_query(['api_key' => $apiKey]);
?>
<img src="<?= $finalUrl ?>">
我已将图片文件上传至梦工厂文件夹
<img src="https://motodev.spotya.online/api/v2/files/Posts/posts_1508937621_Tulips.jpg">
显示错误,
{"error":{"code":400,"context":null,"message":"No session token (JWT) or API Key detected in request.."}
您在 dreamfactory 中的 files
端点似乎已受到保护。您需要提供 API 密钥或 JWT 令牌才能访问此目录中的文件。另一种方法是添加对 files
端点的访客访问,如 here.
您需要像 https://example.org/api/v2/files/image.jpg?api_key=<your api key>
一样生成 url。例如:
<?php
// your guest API key
$apiKey = 'your api key should be here';
// your file URL
$baseUrl = 'https://example.org/api/v2/files/image.jpg';
// resulted URL
$finalUrl = $baseUrl . http_build_query(['api_key' => $apiKey]);
?>
<img src="<?= $finalUrl ?>">