-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework image and file fields to support arbitrary storage endpoints #9529
Conversation
9ee8eaa
to
e2bc89b
Compare
@emmatown since we are here again refactoring it, can you help us with something to create custom storage easily? Like if I want to have Azure storage or Google cloud storage? It would be good to be able to register custom storage and use it with the file/image field. I have been using my own field for s3 which generates 3-4 copy of image processed with sharp to help reduce any compute cost in dynamic image optimization. - https://github.com/keystonejs-contrib/k6-contrib/tree/main/packages/fields-s3images do you see a way to do that with this new refactoring? |
This PR is doing exactly that |
e2bc89b
to
d31873d
Compare
This pull request will additionally add an example for doing a few of the common ones (at least S3, maybe Azure and or GCS) |
a4fca87
to
c135ce8
Compare
c135ce8
to
dd3122e
Compare
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
I see we still keeping multiple fields in database? (_id, .filename, .extension) etc? As there is no filtering applicable to this field, I am thinking we should convert into JSON field internally. This will help adding more data to the field I can add multiple image size in my custom implementation. At least add a meta field |
Interesting idea @gautamsi, but as a breaking change that would be a pretty significant hurdle for many developers wanting to migrate compared to this thus far. Maybe we can posit that as an idea in a different pull request and think about how to help developers migrate? |
@dcousens I understand that migrating such data structure to json will be cumbersome. Adding |
How are you thinking the |
I can save additional information specific to provider or save more information like image metadata (orientation, geocoding etc.) and use that in my frontend/workflow. |
OK, so you want a |
These are all great changes! Also the "node_modules black hole" gets smaller by removing the direct dependency on aws-sdk! Since we're already making breaking changes, could we also address the update problem with these fields? This issue is related to #9419, but the problem is more general. Currently, the order of operations is:
However, uploading is a fragile operation and can fail, leaving us with nothing.
With this approach, we would need to enforce the limitation that transformName must produce a unique string. This is already the case unless the user provides a custom implementation. If this limitation is not practical, the only alternative I see, would be to change the interface. For example, we could introduce a differentiating argument for |
exactly. |
Thank you @emmatown ❤️ Simple and elegant solution. |
93be677
to
cea3fd9
Compare
@gautamsi I don't think I have an answer to your |
would you accept a pull request? |
efadb6a
to
8926297
Compare
8926297
to
4850043
Compare
This replaces the global
storage
config withstorage
config onimage
andfile
fields that directly defines how to upload/delete/get a url for a file so it can be used with any kind of storage provider.The
assets-local
andassets-s3
examples have been updated to work with this though with this API, you could use any other storage provider.Fixes #9419