[英]AWS S3 SDK for PHP: how to get object key from its URL?
Since I'm working on legacy code, I would prefer to keep storing objects' URL and not storing their keys. 由于我正在处理遗留代码,因此我希望继续存储对象的URL,而不存储其键。 Is there any way to get a key from an URL or must I store keys when I upload files?
有什么方法可以从URL获取密钥,还是在上传文件时必须存储密钥?
In general public url to object looks like: 通常,对象的公共url如下所示:
'https://s3-eu-west-1.amazonaws.com/your-bucket/your-directory/file.txt'
where your-directory/file.txt
- is key to object, hence you can parse key from URL. your-directory/file.txt
是对象的键,因此您可以从URL解析键。
But I'd rather keep key in my db because it's easier to work with S3 SDK because you have to provide this key to each method which work with objects in S3. 但是我宁愿将密钥保留在我的数据库中,因为使用S3 SDK更容易,因为您必须为使用S3中对象的每种方法都提供此密钥。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.