-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
chore(platform): delete old images on upload of new ones #2738
chore(platform): delete old images on upload of new ones #2738
Conversation
87cce46
to
3ce1cb1
Compare
@@ -203,6 +208,8 @@ export const action: ActionFunction = getRollupReqFunctionErrorWrapper( | |||
} | |||
|
|||
if (Object.keys(errors).length === 0) { | |||
const ogAppIcon = appDetails.app?.icon |
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.
This is the OAuth logo, not the OG icon. Rename the variable.
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.
Updated, though appIcon
feels closer to the app.icon
than oauthLogo
. Also OG stands for original
, so originalAppIcon
would have been the expanded version.
const imageComponents = input.split('/') | ||
const imageID = imageComponents[imageComponents.length - 2] | ||
|
||
const url = `https://api.cloudflare.com/client/v4/accounts/${ctx.env.INTERNAL_CLOUDFLARE_ACCOUNT_ID}/images/v1/${imageID}` |
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.
I take it the Image API with Custom ID couldn't be used to keep the image URL static and replace the image whenever it gets updated?
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.
I didn't consider that. I can do exploratory work on this if wanted.
28deb15
to
b200a88
Compare
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.
Code doesn't run ("params is undefined" error), likely due to recent changes that have landed on main.
headers: generateTraceContextHeaders(context.traceSpan), | ||
}) | ||
|
||
await imageClient.delete.mutate(oauthLogo) |
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.
Any way to move this outside of the req-res lifecycle, through ctx.waitUntil()
?
headers: generateTraceContextHeaders(context.traceSpan), | ||
}) | ||
|
||
await imageClient.delete.mutate(ogImage) |
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.
Same as other comment, to move out of req-res lifecycle.
@@ -319,6 +336,29 @@ export default function AppDetailIndexPage() { | |||
onChange={() => { | |||
setIsFormChanged(true) | |||
}} | |||
onSubmitCapture={async (event) => { | |||
event.preventDefault() |
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.
As this chunk of code would need to be reused in similar form for the other spots we upload images, would it make sense to refactor into a function that takes some params, like form and the loader effect functions, and takes care of the rest?
b200a88
to
3188ba6
Compare
image upload in console app
Description
Related Issues
Testing
Checklist