File downloading via REST with space in filename won't work

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.

Hi,

I’ve created an issue. Thank you for reporting.

1 Like

Although, maybe there is no issue here.

How did you get the FileRef string? It seems that even in plain FileRef the name part should already be encoded, that is not true for you case.

If you encode the fileRef string (that already has encoded name part) then everything should work.

It’s also the same behaviour when the space %20 is encoded with +.

My question was why your FileRef string contains not encoded name part (name=file with space.pdf)?

s3://2021/09/14/b11111c6-e3de-6cd2-63dd-c5e355f9b1ee.pdf?name=file with space.pdf

For example, when I upload the file called my file.docx, its FileRef string is

fs://2022/07/07/0cfbad56-99a6-a7c7-3432-f1c79832abc9.docx?name=my+file.docx (no space in the name)

After I encode it for using in download URL it looks like this:

fs%3A%2F%2F2022%2F07%2F07%2F0cfbad56-99a6-a7c7-3432-f1c79832abc9.docx%3Fname%3Dmy%2Bfile.docx

The following URL works for me:

http://localhost:8080/rest/files?fileRef=fs%3A%2F%2F2022%2F07%2F07%2F0cfbad56-99a6-a7c7-3432-f1c79832abc9.docx%3Fname%3Dmy%2Bfile.docx&access_token={{access_token}}
1 Like

Hm, yes. I could’ve sworn I tested that as well, but it looks like it’s working.

One thing though: when you download the file, you get a filename where every space is replaced by ‘+’.

Created another issue for this. Thank you.

1 Like