Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides choosing presigned or public URL strategies for MinIO, OSS, and S3 to avoid expiry.
74% 100%+26 ptsof test cases passed
Passed 23 of 23 test cases with the skill, and 17 of 23 without it.
3 of 3 safety checks passed
Not used yet
当使用 MinIO/OSS/S3 等对象存储时,正确选择 URL 生成策略。
场景: 头像、Logo、商品图等需要长期访问的资源
预签名 URL 有时效限制(MinIO/S3 最大 7 天),头像等长期资源会过期导致无法访问。
// ❌ 错误: 预签名 URL 最大 7 天,头像会过期
String avatarUrl = minioService.getPresignedUrl(filePath, 60 * 24 * 365);
// IllegalArgumentException: expiry must be minimum 1 second to maximum 7 days
// ❌ 错误: 即使设置 7 天,头像也会在 7 天后失效
String avatarUrl = minioService.getPresignedUrl(filePath, 60 * 24 * 7);
// 7 天后用户头像显示"图片加载失败"
// ✅ 方案1: 公开 URL(需配置 bucket 公开读)
public String getPublicUrl(String filePath) {
String endpoint = minioConfig.getEndpoint();
if (endpoint.endsWith("/")) {
endpoint = endpoint.substring(0, endpoint.length() - 1);
}
return endpoint + "/" + minioConfig.getBucketName() + "/" + filePath;
}
String avatarUrl = minioService.getPublicUrl(filePath);
// 返回: http://minio:9000/bucket/avatars/xxx.jpeg
Next to this one in the catalogue, plus more from the same author.