Option to conditionally skip a version/transformation #247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a new
:skip
return value on transformations to allow for conditional versions (see #147).A common use is a generic attachment field that accepts any file types. While a thumbnail version would be desirable for a PDF or JPG file, you might not want it for a ZIP file. Just uploading the original file as the "thumbnail" (like
:noaction
does) has several problems, my biggest two being that 1) uploading multiple versions of a large attachment wastes storage space, and 2) there's no indication when fetching URLs that it's really not a thumbnail.With this change, when returning
:skip
fromtransform/2
::noaction
still uploads the original)nil
I added tests, all should be passing (except for the custom S3 bucket test that was already failing before as it's trying to compare a relative path to a full URL).
If this can be merged, I'll have another quick PR for the
arc_ecto
repository as well so it can accommodatenil
urls.Possible changes I can make if needed:
:default
, that will return the default URL for that version as a fallback (instead of nil)