[IMPLEMENTED] Is there a way to reject asset re-uploading?

Is there a way to reject re-uploads to an existing asset? I have a downstream CDN and don’t want my contributors to be in the habit of overwriting an existing asset with different contents because it will not reflect in downstream caching.

You can only use permissions, it is assets.update permission, but it is also responsible for other things.

Can you not just use etags in your CDN?

Sure, ETags are supported, but immediate propagation of the change is not really possible:

  1. The browser may not even request the image based on the Cache-control header, if it has previously been fetched
  2. While we can add CDN cache invalidation via webhooks, it takes time (often minutes) to fully propagate the changes to all edges

We typically instruct our users to always upload and associate new images instead of reusing image urls to avoid any caching confusion, so I was hoping we could programmatically reject asset updates.

Thanks for your response.

We could change the permissions a little bit.

Another option would be to append the file-version to asset urls.

Edit: I think the GraphQL endpoint already does it.

Ok, yea, having the version number is sufficient for my cache busting scenario. In the short term I could shift certain queries over to the GraphQL endpoints.

Do you think you’ll ever support current version numbers on assets when referenced from the REST api? Seems like that would be a breaking change with potential for performance degradation (if done by default), so perhaps some sort of resolveCurrentAssetVersion parameter or the equivalent? (just thinking out loud here)

Either way - I think for the time being I can switch to the GraphQL endpoints when needed to satisfy my requirements. Thanks!

The problem is, that the asset versions are not available in the field data, so I need to resolve the asset itself and in the rest path I do not have the infrastructure for that.

I would avoid to create the same structure that graphql already provides but in a better way.

I have added a dedicated permission for uploading new assets.

1 Like