4
$\begingroup$

I'm trying to download a file hosted on bitbucket via Mathematica. The direct link

https://bitbucket.org/feynmanIntegrals/fire/downloads/FIRE5.2.tar.gz

works fine with Firefox and wget. However, with URLSave all I get

URLSave["https://bitbucket.org/feynmanIntegrals/fire/downloads/FIRE5.\
2.tar.gz", CreateTemporary[]]

is

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAIVFPT2YJYYZY3H4A</AWSAccessKeyId><StringToSign>GET

application/x-www-form-urlencoded
1477322781
/bbuseruploads/fdfbb5c6-4342-4621-9823-cc913478e72e/downloads/75ffeb5e-e570-4a10-9467-d687c3062f32/FIRE5.2.tar.gz?response-content-disposition=attachment; filename="FIRE5.2.tar.gz"&amp;versionId=null</StringToSign><SignatureProvided>Pyu902sDRDMeufUigiM0vDMXJ5c=</SignatureProvided><StringToSignBytes>47 45 54 0a 0a 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 77 77 77 2d 66 6f 72 6d 2d 75 72 6c 65 6e 63 6f 64 65 64 0a 31 34 37 37 33 32 32 37 38 31 0a 2f 62 62 75 73 65 72 75 70 6c 6f 61 64 73 2f 66 64 66 62 62 35 63 36 2d 34 33 34 32 2d 34 36 32 31 2d 39 38 32 33 2d 63 63 39 31 33 34 37 38 65 37 32 65 2f 64 6f 77 6e 6c 6f 61 64 73 2f 37 35 66 66 65 62 35 65 2d 65 35 37 30 2d 34 61 31 30 2d 39 34 36 37 2d 64 36 38 37 63 33 30 36 32 66 33 32 2f 46 49 52 45 35 2e 32 2e 74 61 72 2e 67 7a 3f 72 65 73 70 6f 6e 73 65 2d 63 6f 6e 74 65 6e 74 2d 64 69 73 70 6f 73 69 74 69 6f 6e 3d 61 74 74 61 63 68 6d 65 6e 74 3b 20 66 69 6c 65 6e 61 6d 65 3d 22 46 49 52 45 35 2e 32 2e 74 61 72 2e 67 7a 22 26 76 65 72 73 69 6f 6e 49 64 3d 6e 75 6c 6c</StringToSignBytes><RequestId>039E898261C2178A</RequestId><HostId>96DrO0eeLTSKdX19gOTLP1qP+LbHzcyLZjq6N9zyGjb5fp1fkvbqIqlWPVXqvG1AFBJETdrABBs=</HostId></Error>%

I also tried

URLSave[URLFetch[
   "https://bitbucket.org/feynmanIntegrals/fire/downloads/FIRE5.2.tar.\
gz", "Headers"] /. {___, {"Location", s_}, ___} :> s, 
 CreateTemporary[]]

but this leads to the same result. I see that the file is apparently hosted on Amazon AWS and this seems to be the issue, but given my limited knowledge of Web programming I don't see a way to fix it. Is there some one-line magic to make the download work?

Ideally I would be interested in a solution that works on Mathematica 8 to 11.

Thanks in advance.

P.S. I'm not the owner of the repository and I have no AWS account.

$\endgroup$

1 Answer 1

6
$\begingroup$

Default "Content-Type" header used by Mathematica is confusing Amazon. Setting it manually to empty string works for me:

URLSave["https://bitbucket.org/feynmanIntegrals/fire/downloads/FIRE5.2.tar.gz",
    "Headers" -> {"Content-Type" -> ""}
]
(* "/tmp/74feaab0-90f3-4540-9e3e-054b87b8e60f.tmp" *)

where file with returned path is proper archive file containing FIRE.


Ideally I would be interested in a solution that works on Mathematica 8 to 11.

URLSave was introduced in version 9.0. FetchURL from Utilities`URLTools` works in all versions from 8 to 11:

Needs["Utilities`URLTools`"]
FetchURL["https://bitbucket.org/feynmanIntegrals/fire/downloads/FIRE5.2.tar.gz",
    FileFilters -> {}, "RequestHeaderFields" -> {"Content-Type" -> ""}
]
(* "/tmp/Temp30809___FIRE5.2.tar.gz" *)
$\endgroup$
1
  • $\begingroup$ Thanks, this is indeed the perfect solution to my problem. $\endgroup$
    – vsht
    Commented Oct 24, 2016 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.