-
Notifications
You must be signed in to change notification settings - Fork 541
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
adds method to create image v2 direct upload url #1308
adds method to create image v2 direct upload url #1308
Conversation
changelog detected ✅ |
images.go
Outdated
// CreateImageDirectUploadURLV2 creates an authenticated v2 direct upload url. | ||
// | ||
// API Reference: https://developers.cloudflare.com/api/operations/cloudflare-images-create-authenticated-direct-upload-url-v-2 | ||
func (api *API) CreateImageDirectUploadURLV2(ctx context.Context, accountID string, params ImageDirectUploadURLV2Request) (ImageDirectUploadURL, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update this to align with the library conventions (link)?
i don't love this method name but due to the version existing in the URL, we don't really have much else to offer here. i'll chat with the team internally and see what we can do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...maybe a Version
field on the params struct that toggles the URL and we roll this into the existing create method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CreateImageDirectUploadURLV2
method is significantly different from the existing method and may result into a series of if/else blocks and extracted private methods specific to each version. The request payload is also different between the two versions. The current proposed changes seems like the most clean way to do this. I'm open to other suggestions?
I've updated ImageDirectUploadURLV2Request
with library conventions to use pointers for bool
and time.Time
. Was there anything else you wanted to change to meet the conventions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want V1/V2/V3 as part of the method call since that should be abstracted from end users and they should just be able to configure/control the method as needed instead. i'm fine with private methods that we invoke from inside the shared method with a specific comment documenting it.
as for the library conventions, it looks like the only one missing is the second parameter should be ResourceContainer
, not string
accountID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the input, i've made necessary changes. I ended up keeping all the implementation in the same function to keep it simple for now. Also updated the second parameter to by ResourceContainer
instead of string. Let me know if there are other changes needed.
Codecov Report
@@ Coverage Diff @@
## master #1308 +/- ##
==========================================
- Coverage 48.95% 48.42% -0.53%
==========================================
Files 135 133 -2
Lines 13180 12974 -206
==========================================
- Hits 6452 6283 -169
+ Misses 5212 5173 -39
- Partials 1516 1518 +2
|
i moved this to #1322 because your fork didn't allow maintainers to make edits. |
This PR implements the missing feature to support
images/v2/direct_upload
endpoint that lets client create direct upload url. The
v2
version supportsmetadata
andrequireSignedURLs
as additional request parameters.Description
Since the
v2
request supportsmetadata
andrequireSignedURLs
,a new struct
ImageDirectUploadURLV2Request
is added to images.go.This struct is then passed as a param to
CreateImageDirectUploadURLV2
Closes #1248
Has your change been tested?
Added a unit test for the newly added function. Also tested against a golang
client to create direct upload url with
metatadata
andrequireSignedURLs
,and verified the uploaded image was private and retained all the
metadata
.Types of changes
What sort of change does your code introduce/modify?
Checklist:
and relies on stable APIs.