简体   繁体   English

Amazon S3就像来自php和html的本地文件一样

[英]Amazon S3 as like local files from php and html

I know there's SDK to handle s3 files like uploading and downloading, AND I know s3 files can be accessed by unique url. 我知道有可以处理s3文件(例如上载和下载)的SDK,并且我知道可以通过唯一的url访问s3文件。

HOWEVER, I'd like to know that there's the best easiest way to access files from PHP script and html script like accessing to local files. 但是,我想知道,有一种从PHP脚本和html脚本访问文件的最佳简便方法,例如访问本地文件。

//Example for html -
<img src='/image/1.jpg'>

for this case, I need to change all the url from '/image/1.jpg' to s3 urls. 对于这种情况,我需要将所有网址从“ /image/1.jpg”更改为s3网址。

//Example for php -
$file = 'assets/jquery.js';
echo '<script src='.$file.'></script>';

The only way to access to s3 is that I have to change all local files access relative codes from local directory and file to s3 urls? 访问s3的唯一方法是我必须将所有本地文件访问相关代码从本地目录和文件更改为s3 url?

Changing all full or absolute file path to be s3 url is not a good way. 将所有完整或绝对文件路径更改为s3 url并不是一个好方法。 But is this only way to do so?? 但这是这样做的唯一方法吗?

What about S3FU? S3FU呢? It's not recommended but works properly as other say. 不建议这样做,但可以正常使用。 Only reading files using S3FU and uploading SDK? 仅使用S3FU读取文件并上传SDK? what do you think? 你怎么看?

If you have S3 compatible bucket you can always use CloudBerry for keeping the same "folder structure" 如果您具有与S3兼容的存储桶,则可以始终使用CloudBerry来保持相同的“文件夹结构”

Then only thing you need to do is to prepend all paths with proper domain. 然后,您唯一需要做的就是为所有路径加上适当的域。 Does it solve your problem? 它能解决您的问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM