access to filename of select photo from call to media.show (media.PhotoLibrary, eventHandler)

Got media.show (media.PhotoLibrary, eventHandler) to work

in my eventHandler (event)call back
I dump event table and do not see the name of the image file?

Am I missing something ?

thanks

Ken
[import]uid: 112538 topic_id: 24767 reply_id: 324767[/import]

You do not have access to the Photo Library’s image file. This is by design. Partly because iOS does not provide access to the file because your app is sandboxed. Instead, Corona provides the image in memory as a display object which can be accessed via this event handlers “event.target” property. [import]uid: 32256 topic_id: 24767 reply_id: 100379[/import]

Joshua,

Thanks for your reply…

I am aware of the sandbox issue from the docs. I just want to know the FILENAME because my app is saving the image delivered via the event.target to the sandboxed area ( via display.save )and then sending the saved file via FTP to a server. I wanted to retain the original file name so rather then making up a file name as a workaround.

Is there any way to know the original filename ? I assumed it would be one of the event properties ie. event.filename
(FYI: I am running this as an android app)

Thanks
Ken [import]uid: 112538 topic_id: 24767 reply_id: 100485[/import]

We do not have access to the file name on iOS. Thus, in the interest of being cross-platform, we will not provide access to the file name on any other platform.

That said, you can work-around this issue by telling media.show() to save to file in your app’s local directory instead as shown below. This feature was added to the newest daily builds (not available in release build 704).
[lua]local onComplete = function(event)
if event.completed then
– Image was saved successfully.
else
– User canceled out.
end
end
local filePath = { baseDir = system.TemporaryDirectory, filename = “MyPhoto.jpg” }
media.show( media.PhotoLibrary, onComplete, filePath )[/lua]

Adding that 3rd argument tells media.show() to save to file instead of displaying the selected photo as a display object. The advantage being that the photo will be saved at the same resolution as the original photo in the photo library. Also, the Lua listener’s “event.target” property will be set to nil in this case. If you omit the 3rd file argument, then media.show() will do the old behavior.

One more thing, this feature is currently only supported on iOS and Android. It is not supported on the Corona Simulator yet.
[import]uid: 32256 topic_id: 24767 reply_id: 100625[/import]

Hi Guys,

Newbie here needing some help about displaying photo files. Been searching the forum and site but found no resources yet.

Basically I need help in displaying a set of pics in my app. So what I’m planning is that to have a table or several buttons that correspond to several sets of pics. So it’s like a button will represent a photo album a user can view, zoom, pinch and etc.

Any help would be greatly appreciated.

Many thanks. [import]uid: 123095 topic_id: 24767 reply_id: 101225[/import]

topnotch,

That’s a pretty broad question you are asking. I suggest that you start a new forum thread and ask the community for their suggestions. You might also want to look into using Corona’s “widget” library for the UI. Please see sample app “Interface/WidgetDemo” that is included with the Corona SDK. [import]uid: 32256 topic_id: 24767 reply_id: 101342[/import]

Dear Joshua,

I tried media.show() to save image but it doesn’t save image.
Im using latest build (799) on an iPad retina.

My Code is:

local sessionComplete = function(event)
if event.completed then
local photo = display.newImageRect(“MyImage.jpg”,system.DocumentDirectory,100,100)
end

filePath = { baseDir = system.DocumentDirectory, filename = “MyImage.jpg” }
media.show( media.PhotoLibrary, sessionComplete, filePath )

Please help…
Cheers. [import]uid: 126421 topic_id: 24767 reply_id: 104476[/import]

You have a typo in your code. The documents directory constant needs to be plural like this…
[lua]system.DocumentsDirectory[/lua]

As described on our API page…
http://developer.anscamobile.com/reference/index/system/systemdocumentsdirectory
[import]uid: 32256 topic_id: 24767 reply_id: 104488[/import]

Thank you very much.
Cheers. [import]uid: 126421 topic_id: 24767 reply_id: 104489[/import]