Downloads directory location

I am confused about where files end up when I download them with Downloads.jl. Unfortunately there are no examples in the documentation to follow, so it’s hard to know what I’m doing wrong.

Here’s my attempt at downloading a 1 MB file:

using Downloads
my_file = "https://its-live-data.s3.amazonaws.com/velocity_image_pair/landsatOLI/v01/32607/LT05_L1TP_061018_19951015_20160925_01_T1_X_LT05_L1TP_062018_19950904_20160926_01_T1_G0240V01_P068.nc"
Downloads.download(my_file)

After running the code above, I am expecting to find the downloaded file in my current directory, but it’s not there. When I run the code above, it prints this line:

"/var/folders/3q/36tmwvtx50ldmv31f23wfz7w0000gq/T/jl_fe5urYZmHM"

which might suggest that Downloads put the file in a folder called /var/folders..., but I can’t find that directory on my computer.

The Downloads.jl documentation suggests that something like this might place the file in the current directory:

Downloads.download(my_file,output=pwd())

but the line above produces this error:

ERROR: MethodError: no method matching download(::String, ::Nothing; output="/Users/cgreene/Documents/MATLAB/data_testing")

I also found this thread, which suggests the target location might be entered as the second argument to the downloads function like this:

Downloads.download(my_file,pwd())

but the above produces this error:

ERROR: IOError: rm("/Users/cgreene/Documents/MATLAB/data_testing"): directory not empty (ENOTEMPTY)

Does anyone know where files go when they’re downloaded by Downloads.download()? And is there a way to specify the target location?

I think you should try providing a filename instead of a directory.

1 Like

That’s because the output argument is a positional argument, not a keyword argument (see the documentation). These are not the same in Julia, unlike Python. Also, the output argument is a filename, not a directory. Try:

Downloads.download(my_file, basename(my_file))
1 Like

:person_facepalming: Thanks @GunnarFarneback.

Success! Here’s the working solution:

using Downloads
file_url = "https://its-live-data.s3.amazonaws.com/velocity_image_pair/landsatOLI/v01/32607/LT05_L1TP_061018_19951015_20160925_01_T1_X_LT05_L1TP_062018_19950904_20160926_01_T1_G0240V01_P068.nc"
target_directory = "/Users/cgreene/Documents/MATLAB/data_testing";
target_file = target_directory * "/" * basename(file_url)
Downloads.download(file_url,target_file)

Thanks @stevengj!

1 Like

Still waiting for this to be merged so you don’t have to do the extension back yourself

1 Like