Downloading a compressed archive folder from a URL

3 views (last 30 days)
I'm trying to download a compressed archive folder such that the download is initiated when I click the link.
The folder name appears to be 'grace_1B_2002-04-08_02.tar' once downloaded.
The code I generated downloads an html file (code is attached herewith). Could anyone please help me fix the code. (R2023a)
% Set the URL for the folder download link
folderURL = 'https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/GRACE_L1B_GRAV_JPL_RL02/2002/grace_1B_2002-04-04_02.tar.gz';
% Set the destination folder where you want to save the downloaded folder
destinationFolder = 'path_to_your_destination_folder';
% Set the filename for the downloaded folder
filename = 'grace_1B_2002-04-04_02.tar';
% Construct the full path for the destination file
fullDestinationPath = fullfile(destinationFolder, filename);
% Download the folder
try
websave(fullDestinationPath, folderURL);
fprintf('Downloaded %s\n', filename);
catch
fprintf('Error downloading %s\n', filename);
end
Thanks in advance

Accepted Answer

Cris LaPierre
Cris LaPierre on 18 Dec 2023
It is a secure site only accessible to signed-in users. I found I could successfully download the file if my request also included my username and password, which were set using weboptions.
url = 'https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/GRACE_L1B_GRAV_JPL_RL02/2002/grace_1B_2002-04-04_02.tar.gz';
opts = weboptions('Username','myUserName','Password','myPassword');
websave('grace_1B_2002-04-04_02.tar.gz',url,opts)

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!