unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
1.54k stars 61 forks source link

Pluggable sources #86

Closed aaharu closed 1 year ago

aaharu commented 1 year ago

Do you have any plans to make sources pluggable?

I want to use other sources, like the S3, Cloud Storage, etc. But it's needed to folk and add logic to Init sources and getSrc.

pi0 commented 1 year ago

Hi. I belive this would be possible with #135 leveraging unstorage providers.

sondh0127 commented 1 year ago

Would you be able to give me a hint on how to make a S3 storage? @pi0 thanks

thunder-al commented 1 year ago

Would you be able to give me a hint on how to make a S3 storage? @pi0 thanks

for now, the only way to use s3 as images source is make this s3 image storage public and guard ipx with this s3 domain.

but, you can create your own ipx instance by rewriting createIPX function to work with s3 and provide this custom instance to middleware

in my case: I have separated backend (non h3, I use fastify or adonis), so I implemented same url parsing technique and bind it with "s3 read-file-as-stream" with sharp image pipeline and custom cache storage. it is pretty simple