MATLAB Answers

Download files from https server using username and password

9 views (last 30 days)
sermet OGUTCU
sermet OGUTCU on 12 Aug 2021
Commented: sermet OGUTCU on 4 Oct 2021 at 18:08
url = 'https://cddis.nasa.gov/archive/gnss/products/0971/';
In this https server, I need to download "cod09710.eph.Z" file for a specific location in my computer. How I can download this file using username and password related to this https server?

Accepted Answer

Rik
Rik on 12 Aug 2021
You should be able to use websave. You can provide a username and password in weboptions:
weboptions
ans =
weboptions with properties: CharacterEncoding: 'auto' UserAgent: 'MATLAB 9.10.0.1716447 (R2021a) Update 4' Timeout: 5 Username: '' Password: '' KeyName: '' KeyValue: '' ContentType: 'auto' ContentReader: [] MediaType: 'auto' RequestMethod: 'auto' ArrayFormat: 'csv' HeaderFields: [] CertificateFilename: 'default'
  7 Comments
sermet OGUTCU
sermet OGUTCU on 4 Oct 2021 at 18:08
Dear @Andre,
I use GAMP II open source software for downloading from the CDDIS. You can run GAMP II independently or using MATLAB.

Sign in to comment.

More Answers (1)

Yongjian Feng
Yongjian Feng on 12 Aug 2021
Try this:
username = 'Your username here';
password = 'Your password here';
authStr = [username ':' password];
base64Str = ['Basic ' matlab.net.base64encode(authStr)];
headers = {'Authorization': base64Str};
options = weboptions('HeaderFields',headers);
webread('http://ip.jsontest.com', options)
  6 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!