簡體   English   中英

如何使用php從Dreamfactory中顯示文件文件夾中的圖像

[英]How to display images in files folder from dreamfactory using php

我已將圖片文件上傳到Dreamfactory的文件夾中

<img src="https://motodev.spotya.online/api/v2/files/Posts/posts_1508937621_Tulips.jpg">

顯示錯誤

{“錯誤”:{“代碼”:400,“上下文”:null,“消息”:“在請求中未檢測到會話令牌(JWT)或API密鑰。”}

看來您在dreamfactory中的files終結點已得到保護。 您需要提供API密鑰或JWT令牌才能訪問此目錄中的文件。 另一種方法是來賓訪問添加到您的files的端點,描述在這里

您需要生成類似https://example.org/api/v2/files/image.jpg?api_key=<your api key>網址。 例如:

<?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 ?>">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM