Skip to content

Support attachments with spaces in filename. #368

@maxceem

Description

@maxceem

Looks like attachments with spaces in filenames are not supported in the moment. Probably some other characters would cause the same issue.

  • I'm trying to upload a file with the name file name with space.txt.
  • I use FileStack to upload it to AWS S3 and get the next URL in AWS:
    https://tc-challenge-v5-dev.s3.amazonaws.com/challenges/b4d2416b-0e4a-4ef7-87c7-9cbc825fc0ab/SPECIFICATION_ATTACHMENTS/Gve9N2DZQdKsxVcnQb4x_file name with space.txt
    
  • Now if I try to create an attachment using the a POST request with the next body, I would get error: {"message":"\"url\" must be a valid uri"}
      [{
          "name":"file name with space.txt",
          "fileSize":4,
          "url":"https://tc-challenge-v5-dev.s3.amazonaws.com/challenges/b4d2416b-0e4a-4ef7-87c7-9cbc825fc0ab/SPECIFICATION_ATTACHMENTS/Gve9N2DZQdKsxVcnQb4x_file name with space.txt"
     }]

I tried to overcome this validation by endocing the URL with encodeURI and create attachments like this:

[{
  "name":"file name with space.txt",
   "fileSize":4,
   "url":"https://tc-challenge-v5-dev.s3.amazonaws.com/challenges/b4d2416b-0e4a-4ef7-87c7-9cbc825fc0ab/SPECIFICATION_ATTACHMENTS/LAFBdm1MSIyoZzdDYNRK_file%20name%20with%20space.txt"
}]

Then attachment is created successfully:

[{"id":"a6ab452e-22c1-4348-b2ab-6e7dda5da0c3","challengeId":"b4d2416b-0e4a-4ef7-87c7-9cbc825fc0ab","name":"file name with space.txt","fileSize":4,"url":"https://tc-challenge-v5-dev.s3.amazonaws.com/challenges/b4d2416b-0e4a-4ef7-87c7-9cbc825fc0ab/SPECIFICATION_ATTACHMENTS/LAFBdm1MSIyoZzdDYNRK_file%20name%20with%20space.txt"}]

Though, if I'm trying to download it via https://api.topcoder-dev.com/v5/challenges/b4d2416b-0e4a-4ef7-87c7-9cbc825fc0ab/attachments/a6ab452e-22c1-4348-b2ab-6e7dda5da0c3/download?token=<TOKEN> I'm getting {"message":"Internal server error"}

cc @ThomasKranitsas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions