0

How can I open a file in GDAL from a SMB (or CIFS) server without storing the file in memory?

I want to do something like this:

import smbclient
from osgeo import gdal
with smbclient.open_file('//server/input.tif', username='user', password='pass', mode='rb') as f:
    gdal.Translate(f, 'output.tif')

I have seen some example using f.read(), but that loads entire file into memory.

4
  • You might have to mount/map a folder to the server.
    – user2856
    Commented Jun 10 at 6:30
  • I want to run it in a Docker container and don't run it as privileged. @user2856
    – Math-dude
    Commented Jun 10 at 18:53
  • You won't be able to use smbclient to access directly files with GDAL. You will either have to copy the file locally using smbclient, or don't use smbclient and mount the server share when you run the docker container (you might be able to run rootless docker with a fuse mount?).
    – user2856
    Commented Jun 10 at 22:13
  • I have been able to mount it with fstab, and run as none-root, but I still have to run it as a privileged container. But thanks for the hint. I will google more around fuse. @user2856
    – Math-dude
    Commented Jun 11 at 18:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.