Difference between revisions of "Share:export"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2024.1<br/> '''Class:''' Share<br/> === Description === Exporting a piece of data to the phone via default file application. <syn...")
(No difference)

Revision as of 19:55, 20 February 2025

Available since: Gideros 2024.1
Class: Share

Description

Exporting a piece of data to the phone via default file application.

(bool) = Share:export(data,mimeType,filename)

This invokes the platform default file application.

Parameters

data: (varies) the data to export (text String or image data)
mimeType: (string) the MIME type of the exported data
filename: (string) the name the file will be saved to

Return values

Returns (boolean) true if data can be exported

Examples

Text

require "Share"

local share = Share.new()

share:export("Hello Gideros!", "text/plain" , "hello.txt") -- data, MIME type, file name

share:addEventListener(Event.SHARE_EXPORT_RESULT, function(e)
	print("share:export callback:", e and e.status)
end)

Image

require "Share"

local share = Share.new()

local img = io.open("gfx/cat.jpg")
local rimg = img:read("*all")

share:export(rimg, "image/jpeg", "cat1.jpg") -- data, MIME type, file name

share:addEventListener(Event.SHARE_EXPORT_RESULT, function(e)
	print("share:export callback:", e and e.status)
end)