Page 1 of 1

can't open/modify files stored on MTP device (phone)

Posted: 2022-01-01 11:23
by maze
I have an Android phone that connects to my computer through the MTP protocol. in general it works well. using my file explorer (Thunar), I can browse folders, move, copy and delete stuff. however, opening files doesn't work. I either get an empty file (e.g. when I try to open pictures with GIMP or Nomacs), or get an error (e.g. when I try to open a PDF with Evince: "Unable to open document “file:///tmp/evince-2/document.KKDQF1-documentname.pdf”, libmtp error: Could not create file.").

this is really annoying, because I need to copy each file separately to my local drive if I want to open it, and even copy it back and overwrite it if I want to modify it.

how can I open and edit files on an MTP device?

I'm using Debian 11.1.

MTP-related packages installed:
gmtp/stable,now 1.3.11-3 amd64 [installed]
go-mtpfs/stable,unstable,testing,now 1.0.0-1+b5 amd64 [installed]
libmtp-common/stable,stable,now 1.1.17-3 all [installed]
libmtp-runtime/stable,now 1.1.17-3 amd64 [installed]
libmtp9/stable,now 1.1.17-3 amd64 [installed]
libnet-smtp-ssl-perl/stable,stable,unstable,unstable,testing,testing,now 1.04-1 all [installed,automatic]
mtp-tools/stable,now 1.1.17-3 amd64 [installed]

Re: can't open/modify files stored on MTP device (phone)

Posted: 2022-01-09 13:31
by pylkko
AFAIK Microsoft deliberately designed mtp to work like that. There can be only one connection at a time and you cannot open the files in place.. this is to prevent problems in case of accidental disconnection. So, for example in Windows, when you use the drive, the OS copies the entire content to a temp location in the machine.
see: https://www.2brightsparks.com/resources ... tocol.html

Because MTP is implemented in different phones in different ways, has some strange bugs (such as the files now showing bug since 2012), I tend to think that it is just simple to not use MTP. There is even an app called mtp alternative, becasue MTP is so annoying to use.

Other ways to access files on the phone include using ADB shell, or even simpler, installing a file manager that can create an ftp server. There is a open source app called "Amaze", but there are many many different alternatives. Once you have this, all you need to do is access the files wirelessly with ftp. This can be done over LAN, but also over an ad hoc network (i.e the phone as an access point). All that you need is a computer with WIFI antenna