FileCodeBox icon indicating copy to clipboard operation
FileCodeBox copied to clipboard

对象存储能否直接返回直链而不是通过服务器中转

Open IcedWatermelonJuice opened this issue 10 months ago • 3 comments

S3对象存储能否增加一个选项,如果是甚至时长的情况下,允许直接返回直链(通过ExpiresIn控制时长)? 现在似乎用的是中转逻辑:用户向FileCodeBox请求-> FileCodeBox从S3读 -> 缓存文件推流给用户。 这种逻辑可能不太适合个人服务器(小水管下载太慢了)。

IcedWatermelonJuice avatar Apr 28 '25 03:04 IcedWatermelonJuice

s3目前可以生成临时链接吧,除非手动设置代理模式


    async def get_file_url(self, file_code: FileCodes):
        if file_code.prefix == "文本分享":
            return file_code.text
        if self.proxy:
            return await get_file_url(file_code.code)
        else:
            async with self.session.client(
                    "s3",
                    endpoint_url=self.endpoint_url,
                    region_name=self.region_name,
                    config=Config(signature_version=self.signature_version),
            ) as s3:
                result = await s3.generate_presigned_url(
                    "get_object",
                    Params={
                        "Bucket": self.bucket_name,
                        "Key": await file_code.get_file_path(),
                    },
                    ExpiresIn=3600,
                )
                return result

vastsa avatar Apr 28 '25 13:04 vastsa

对象存储上传下载都应该是直链,要不然没啥意义

liubaicai avatar May 13 '25 07:05 liubaicai

目前S3测试上传下载还是会经过服务器中转

Omoinemie avatar Oct 13 '25 03:10 Omoinemie