How to get a file from a multi-page HTTP response (OGC WCS service) using Python

I retrieve the multipart results as socket._fileobject (fo) from the OGC WCS service, where the result of fo.read () is as follows:

--wcs
Content-Type: text/xml
Content-ID: wcs.xml

<?xml version="1.0" encoding="UTF-8"?>
<Coverages
     xmlns="http://www.opengis.net/wcs/1.1"
     xmlns:ows="http://www.opengis.net/ows"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.opengis.net/ows/1.1 ../owsCoverages.xsd">
  <Coverage>
    <Reference xlink:href="cid:coverage/out.tif"/>
  </Coverage>
</Coverages>
--wcs
Content-Type: image/tiff
Content-Description: coverage data
Content-Transfer-Encoding: binary
Content-ID: coverage/out.tif
Content-Disposition: INLINE
(a lot of binary data)--wcs--

I need to save the binary part of a file to a file (out.tif). Could you advise me some Python library for its use and write an example of use?

Thank!

+3
source share

All Articles