Download the pictures from the iPhone camera problems

Hello!

I am developing an app to take photos and then download...

I have this methods to show the camera and get some pictures

public function showCamera (): void {}

If {(CameraUI.isSupported)

camera = new CameraUI();

camera.addEventListener (MediaEvent.COMPLETE, onComplete);

Camera.Launch (MediaType.image);

}

}

private void onComplete(event:MediaEvent):void {}

var mp:MediaPromise = event.data;

This.image_url = mp.file.url;

}

The problem is mp.file.url is null in the iPhone, much I read about it and found this solution, it is load the last image in the memory by using the context loader, I do this way:

private function onCameraUIComplete(e:MediaEvent):void
{
  var cameraUI:CameraUI = e.target as CameraUI;
  cameraUI.removeEventListener(MediaEvent.COMPLETE, onCameraUIComplete);
  cameraUI.removeEventListener(Event.CANCEL, onCameraUICanceled);
  cameraUI.removeEventListener(ErrorEvent.ERROR, onCameraError);
                 
  mediaPromise = e.data;
                    
  this.mpLoader = new Loader();
  this.mpLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMediaPromiseLoaded);
  this.mpLoader.addEventListener(IOErrorEvent.IO_ERROR, onMediaPromiseLoadError);
  this.mpLoader.loadFilePromise(mediaPromise);
}
          
private function onMediaPromiseLoaded(e:Event):void
{
  var mpLoaderInfo:LoaderInfo = e.target as LoaderInfo;
  mpLoaderInfo.removeEventListener(Event.COMPLETE, onMediaPromiseLoaded);
  mpLoaderInfo.loader.removeEventListener(IOErrorEvent.IO_ERROR, onMediaPromiseLoadError);
  this.imgPhoto.source = mpLoaderInfo.loader;         //adding photo to image display in the screen
//adding photo to camera roll
  var bitmapData:BitmapData = Bitmap(e.target.content).bitmapData;
  addToCamaraRoll(bitmapData);
}

My question is, how to convert the LoaderInfo result as a file o o get FileReference, o how convert Bitmap or bitmapData into a file. I need a file or FileReference download a server.

(Maybe a little late for the original poster) I wrote an article on download of images from the CameraRoll and CameraUI classes which addresses differences Android/iOS: http://www.adobe.com/devnet/air/articles/uploading-images-media-promise.html

Tags: Flex

Similar Questions

Maybe you are looking for