I am trying to send an image (it can't be a file, must be a base64) to another app using the URI scheme and the Xamarin Launcher.
var uri = new Uri(url);
await Launcher.OpenAsync(uri); // await Launcher.OpenAsync(url);
Both: new Uri(url)
and await Launcher.OpenAsync(url)
give an exception if the url lenght is over 2000 characters.
As I know, passing base64 strings to other apps (for example to edit an image or print a document) is normal. So why does Xamarin limit it to 2000 characters?
Is there a workaround?
Edit:
Exception on new Uri
:
System.UriFormatException: Invalid URI: The Uri string is too long.
at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/UriExt.cs:55
at System.Uri..ctor (System.String uriString) [0x00014] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/URI.cs:408
Exception on Launcher.OpenAsync
:
System.UriFormatException: Invalid URI: The Uri string is too long.
at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/UriExt.cs:55
at System.Uri..ctor (System.String uriString) [0x00014] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/URI.cs:408
at Xamarin.Essentials.Launcher.OpenAsync (System.String uri) [0x00013] in D:\a\1\s\Xamarin.Essentials\Launcher\Launcher.shared.cs:32
It seems that this is the limitation of System.Uri class. While it is not officially documented if you search you will find this being discussed on many places like here: https://social.msdn.microsoft.com/forums/en-US/6435996c-4b96-4887-be60-f6e10120f0a0/long-http-get-requests-and-a-uri-max-length-constraint
Basically you have to use the native classes to achieve what you want.