Getting the size of a file via API

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
alaroy
Posts: 78
Joined: Tue Nov 21, 2006 3:33 pm America/New_York
Answers: 0

Getting the size of a file via API

by alaroy » Thu Aug 29, 2019 11:48 am America/New_York

Is there any way to determine the byte size of a file on your data server using the file_search, getfile or other cgi tools?

We have cases where we want to ignore files below a certain size. It would also be nice to compare the remote and local file sizes to verify that the file wasn't truncated. The only way I've been able to figure out how to get the size is to download the file and then check the size of what you fetched (which is rather a waste of time and bandwidth)

Thank you,
-Andrew L.

Tags:

OB.DAAC - SeanBailey
User Services
User Services
Posts: 1470
Joined: Wed Sep 18, 2019 6:15 pm America/New_York
Answers: 1
Been thanked: 5 times

Getting the size of a file via API

by OB.DAAC - SeanBailey » Thu Aug 29, 2019 10:48 pm America/New_York

If you call the api with format=json you'll get a json output that includes the filesize in bytes, e.g:

$ wget -q --post-data="search=A2019240165500.L1A_LAC&format=json"                        
https://oceandata.sci.gsfc.nasa.gov/api/file_search -O A2019240165500.L1A_LAC.json       
                                                                                         
$ cat A2019240165500.L1A_LAC.json                                                        
{"A2019240165500.L1A_LAC.bz2":{"cdate":"2019-08-28 14:16:00","checksum":"sha1:d1cfc74644a4c3bc5f7c7850b547c6c176de50a2","size":226190606}}


Sean

Post Reply