Page 1 of 1

Getting the size of a file via API

Posted: Thu Aug 29, 2019 11:48 am America/New_York
by alaroy
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.

Getting the size of a file via API

Posted: Thu Aug 29, 2019 10:48 pm America/New_York
by OB.DAAC - SeanBailey
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