The request looks something like this:
https://example.com/rest/files?fileRef=s3%3A%2F%2F2021%2F09%2F13%2Fb11111c6-e3de-6cd2-63dd-c5e355f9b1ee.pdf%3Fname%3Dfile%20with%20space.pdf&access_token=asdfasdfasdfasdf
Sending the request URL encoded or not makes no difference, it always throws a:
Invalid file reference: Cannot convert 's3://2021/09/14/b11111c6-e3de-6cd2-63dd-c5e355f9b1ee.pdf?name=file with space.pdf' into valid file reference
Removing the spaces from the name
attribute solves the issue, but then we can’t use spaces in the filenames.