@applejack
The hint is in the text you provided. It says you have to upload the file using the Submission Comments API file section. That takes us to the Submissions Comments API where there is, indeed, an upload a file endpoint.
It gives you the endpoint to initiate the file upload, but directs you to the file upload documentation (don't jump there directly, start with the Submissions Comments and read what's there). The final step will return attachment data including the new file ID, that you can then use with the PUT that you provided.
In step 1, you upload via POST using the /api/v1/courses/:course_id/assignments/:assignment_id/submissions/comments/self/files endpoint. You supply the file name, size, and possibly content_type. This gives you a file object in pending state, which is valid for 30 minutes (you must complete the upload within 30 minutes).
In step 2, you upload the file data to the URL provided in step 1. This is not an API call. The parameters come with the response from step 1.
I've not needed to use step 3 when uploading files because I get the 201 status code. If you get a 3xxs redirect, you need to get that location to complete the upload. It's likely that you could set your fetch statement to follow redirects and automatically do this.
After the 201 status code, you'll get an object with the file_id you need.