Serve R2 content only if content starts with certain file signature

I’m a C# and Go Developer and unfamiliar with the tech stack of workers, some guidance would be helpfull.

I want to create a Worker which serves content from a R2, but only if the content of the file is from the format https://github.com/C2SP/C2SP/blob/main/age.md (starting with age-encryption.org or PEM encoded value starts with age-encryption.org. If the condition is not meet, the works returns just a HTTP Error Status Code.

Optional I can POST files with the same file conditions, these are saved under a random file name which url will be return after successful upload.