Code-Hex / pget

The fastest, resumable file download client
MIT License
1.14k stars 78 forks source link

Error: file name too long #52

Open balazser opened 2 years ago

balazser commented 2 years ago

On Linux using Pget 0.1.1 installed by linuxbrew I'm getting the following error when I download a binary. How could we fix it?

$ pget https://github.com/42wim/matterbridge/releases/download/v1.25.0/matterbridge-1.25.0-linux-64bit

Error:
  failed to mkdir for download location: mkdir _a44ac081-f540-4721-ae1f-05c2bdd363cf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220502%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220502T142130Z&X-Amz-Expires=300&X-Amz-Signature=db8edd56f819399d6040d92ced71cba3fa7b2d7b94d5cd6255f33d7e092567f5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=44820350&response-content-disposition=attachment%3B%20filename%3Dmatterbridge-1.25.0-linux-64bit&response-content-type=application%2Foctet-stream.1: file name too long
septs commented 2 years ago

I think Pget needs this feature (wget --content-disposition) by default enabled

see https://www.gnu.org/software/wget/manual/wget.html#index-Content_002dDisposition see https://mdn.io/Content-Disposition

septs commented 2 years ago

https://github.com/mirror/wget/blob/aab539bb44b5d7aeb093014c21fd4f4e4e728136/src/http.c#L1221-L1299

on Golang

if mediaType, params, _ := mime.ParseMediaType(resp.Header.Get("Content-Disposition")); mediaType == "attachment" {
    if remoteFilename, ok = params["filename"]; ok {
        task.Filename = remoteFilename
    }
}

CC @Code-Hex