1

I was following this tutorial http://developer.xamarin.com/recipes/ios/media/video_and_photos/choose_a_photo_from_the_gallery/ and I can get the path for a video just by doing

mediaURL.Path

but with an image it returns something like

"assets-library://asset/asset.JPG?id=2A456415-B1AE-414A-9795-A0625K768EBD&ext=JPG"

and I can not use it to upload to my server because using FileInfo("imageLocaltion") will not find the file.

So with urls like the above how can I access the "real" file path?

nhenrique
  • 874
  • 1
  • 16
  • 35

1 Answers1

3

See "display image from URL retrieved from ALAsset in iPhone" - the same mechanisms apply to Monotouch:

Community
  • 1
  • 1
asp_net
  • 3,567
  • 3
  • 31
  • 58
  • thanks! Using those mechanisms I can now reach the correct filename and a lot more metadata – nhenrique Mar 30 '15 at 11:41
  • I'm still having some troubles in getting the url to use for upload something from the gallery. I can display the photo just fine but where's the real url for the file? All urls are //assets-library/...something .. – nhenrique Mar 30 '15 at 11:57
  • Have you tried to read the file with File.ReadAllBytes() for example? – asp_net Mar 30 '15 at 13:21
  • yes, it says "Could not find a part of the path" because its adding the path "assets-library://asset/asset.JPG?id=2A4564.." to my app directory path. Using just "assets-library://asset/asset.JPG?id=2A4564.." says that it can't find the file – nhenrique Mar 30 '15 at 13:39
  • any ideas on what to do here? – nhenrique Apr 08 '15 at 14:43
  • I have no idea if it's possible to access a file by it's known path with that protocol, but I guess it's not. Instead take that image out of the library and save it to one of your app's folders. See http://developer.xamarin.com/guides/ios/application_fundamentals/working_with_the_file_system/ for more information. – asp_net Apr 08 '15 at 16:12