gdal icon indicating copy to clipboard operation
gdal copied to clipboard

SFTP support in VSI Curl

Open jdesboeufs opened this issue 1 year ago • 4 comments

Hello,

I tried to use sftp:// protocol with /vsicurl/ since it is supported by libcurl. It didn't work!

After further investigation, I found that only https://, http:// and ftp:// were allowed in GDAL. Is there a reason or is it possible to change this behavior?

I did some changes in cpl_vsil_curl.cpp but a simple gdalinfo still fail.

Any idea on this? Why most of curl-supported protocols are filtered by GDAL?

Thank you in advance. I'm ready to work on a PR.

jdesboeufs avatar Oct 11 '23 21:10 jdesboeufs

Apparently, according to https://curl.se/libcurl/c/CURLOPT_RANGE.html, sftp:// should support range requests, so that's a good precondition. Why it doesn't work? I don't know. Would require debugging... Well possible that there are some HTTP assumptions somewhere. FTP support is no longer tested, so not impossible it is broken.

A good candidate is where CURLINFO_HTTP_CODE is tested in cpl_vsil_curl.cpp (CURLINFO_HTTP_CODE is actually an alias to https://curl.se/libcurl/c/CURLINFO_RESPONSE_CODE.html), since apparently this only works for HTTP and FTP

Why most of curl-supported protocols are filtered by GDAL?

the famous motto: "what is not tested is (most certainly) broken"

rouault avatar Oct 11 '23 22:10 rouault

is there still interest in keeping this opened?

rouault avatar Feb 19 '24 20:02 rouault

I'm not sure if there will new FTP-sites coming. But at least some are still available: https://www.skogsstyrelsen.se/sjalvservice/karttjanster/geodatatjanster/ftp/

Yes, page is in Swedish, but I guess you can find address, username and password from the site.

posikifi avatar Feb 20 '24 06:02 posikifi

Hi,

We ended up in creating a HTTP proxy to these protocols, with a simple token-based authentication and supporting range requests. Then we build /vsicurl/https path to read information from the datasets.

This work-around allows us to extract metadata from thousands of JPEG2000/GeoTIFF stored in FTP/SFTP in couple of minutes.

jdesboeufs avatar Feb 22 '24 07:02 jdesboeufs