obsidian-imgur-plugin icon indicating copy to clipboard operation
obsidian-imgur-plugin copied to clipboard

Enable for mobile

Open piranha opened this issue 3 years ago • 3 comments

Hey! This plugin is enabled for desktop only right now. Do you think it's possible to enable it for mobile app? :)

piranha avatar Jul 23 '21 08:07 piranha

Hi @piranha. I tried it on mobile by manually uploading it to mobile vault and changing isDesktopOnly in manifest, but it does not work "as-is". This plugin uploads images on:

  • "drag" (when you use drag-and-drop) and
  • "paste" (when you paste from the clipboard buffer) events

On mobile you are also allowed to add images from the gallery to your note. But looks like none of those events are used. I posted a quick question on Discord about how it works, but the question left unanswered.

So, in short:

  • you can attach images from the gallery on mobile
  • so I think there must be a way to override the default behaviour and perform remote upload instead. But for now I do not know which event is involved into this process ​

When I developed for desktop, there was a Chrome console which helped me a lot. For mobile, I do not know yet how to easily debug. There was a message in the chat on how to connect to remote console, but I haven't tried that yet.

Do you know if copy-paste is available for images on mobile platforms? I have an Android phone. I have a "Copy" context menu option in Chrome browser. When I go to Obsidian, and try to "Paste", simply nothing happens. At the same time if I go to Telegram and Paste the image previously copied from Chrome, it works! I think Obsidian for Android does not handle paste event as we and the current implementation of imgur plugin expects. If you have an iOS device, please let me know if you can copy/paste images there (with other, more mature apps) and if Obsidian can handle it or not

gavvvr avatar Jul 23 '21 09:07 gavvvr

Yeah, I have an iOS device and nothing happens. I also installed an iPad version on macOS and nothing happens on pasting an image there. So I guess mobile app has no support for pasting anything but text right now.

piranha avatar Jul 23 '21 10:07 piranha

Tried with iPhone too -> same result. Nothing happens on "paste" context menu item.

I created the feature request on Obsidian forums to support "pasting" images on mobile.

gavvvr avatar Jul 24 '21 00:07 gavvvr

I have no idea about the events involved when pasting on mobile platforms. But there is a plugin that enables a dev console on mobile (I’ve only tried it on iOS). I think it needs to be installed manually, but it worked fine for me. Debugging this way is still cumbersome, but at least it’s something 😌

martinjo avatar Oct 21 '22 10:10 martinjo

"This plugin does not support your device"

My situation is the following : I can't even enable the plugin on ipadOS, because (as is often the case) I get this red notice : "This plugin does not support your device". I wonder if this is easily fixable. Would love to learn how to fix this kind of thing as it is a recurring pbm with obsidian plugins on mobile.

Anyway, I have a feeling that the conversation has gotten a bit old and I'm not quite sure we're refering to the same issue : it seems that people here are refering to pasting images from a clipboard, which has only been made possible very recently on obsidian mobile ( forum.obsidian ).

A000045 avatar Feb 25 '23 11:02 A000045

Hi @A000045

You can easily fix this error message by opening the vault which you had on PC and changing one line in manifest.json.

  1. Create the vault on PC
  2. Install Imgur plugin
  3. Go to your_vault/.obsidian/plugins/obsidian-imgur-plugin/manifest.json and change the value for isDesktopOnly to false
  4. Somehow copy your vault to your mobile device (as an Android user, I use OneSync to sync my knowledge base between PC and mobile device)
  5. Open the vault which you just copied using mobile app. The plugin should be able to be "Enabled", but as I know it does not work on mobile (still did not find a time to debug it on mobile devices).

gavvvr avatar Feb 27 '23 05:02 gavvvr

Today I've spent my morning on understanding why it does not work on mobile. It turned out to be surprisingly easy to enable debugging on mobile:

  1. enable USB debugging on Android phone
  2. connect it with USB to laptop
  3. open chrome://inspect right in the browser and choose Obsidian mobile app

So, I opened the "Network" tab to understand what's wrong and first thing I saw was net::ERR_HTTP2_PROTOCOL_ERROR on request itself and TypeError: Failed to fetch exception. After more attempts to upload an image the error turned into 429 with human-readable payload:

{
    "data": {
        "error": "Imgur is temporarily over capacity. Please try again later."
    },
    "success": false,
    "status": 403
}

I compared requests from desktop and mobile Obsidian apps and one major difference is that the Origin header from mobile app is http://localhost, while it is app://obsidian.md for Desktop app. Then the "try again later" message makes sense to me, there are always too many requests from http://localhost from around the world or it's a kind of banned forever by target servers, even though it's not explicitly prohibited by CORS.

I've posted a question on Obsidian forums about the possibility to get non-localhost value for Origin header in mobile app. Let's see. If that's not possible even for Obsidian developers to affect this header for mobile app, then this feature will never be implemented.

gavvvr avatar Oct 08 '23 08:10 gavvvr

Finally available in v2.4.0 🎉 (just released)

gavvvr avatar Oct 20 '23 13:10 gavvvr