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 (starting with or PEM encoded value starts with 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.