Gio.File.new_for_uri fails on Gtk3/Python3 but works on Gtk2/Python2

I have a simple program:

    caa_image_url = ''
    giofile = Gio.File.new_for_uri(caa_image_url)

On a platform running Gtk2 and Python2, giofile is __gi__.GDaemonFile. On a platform running Gtk3 and Python3 it is __gi__.GDummyFile. The latter does not support any subsequent operations (e.g., read). Presumably it indicates that something went wrong with the new_for_uri. The glib networking packages on the platform where the command does not work are version 2.72. On the other platform they are version 2.48. I suspect that some package is missing on the platform where the command fails, but I cannot figure out what it might be. Any suggestions appreciated.

Python2/Gtk2 is unsupported, and has nothing to do with Gio.

GIO is also not used to access/download files from a web server: it’s a file browsing API.

What are you trying to achieve?

Thank you for replying.

I figured out that I needed to install gvfs-backends.

I am using Gio.File to aynchronously download image files from a web server. It works, but should I be using something else?

Yes: you should use libsoup. Using Gio.File is not recommended for that use case, unless you’re writing a WebDAV file browser.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.