Share.share: Difference between revisions

From GiderosMobile
m Text replacement - "</source>" to "</syntaxhighlight>"
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
<languages />
'''Available since:''' Gideros 2020.7<br/>
'''<translate>Available since</translate>:''' Gideros 2020.7<br/>
'''Class:''' [[Share]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/Share|Share]]<br/>
 
=== <translate>Description</translate> ===
=== Description ===
<translate>Share a piece of data with an external app. This invokes the platform default sharing dialog, allowing to save, print, send, share, etc. <br />
Share a piece of data with an external app. This invokes the platform default sharing dialog, allowing to save, print, send, share, etc.
<syntaxhighlight lang="lua">
Share.share(mimeType,data)
</syntaxhighlight>
 
Supported MIME types:
Supported MIME types:
* text/*
* '''"text/*"'''
* image/png
* '''"image/png"'''
* image/jpeg
* '''"image/jpeg"'''


</translate>
=== Parameters ===
'''mimeType''': (string) the MIME type of the data<br/>
'''data''': (string) the data itself<br/>
 
=== Example ===
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Share.share(mimeType,data)
local b = Buffer.new("diploma.jpg")
rt:save("|B|diploma.jpg")
local bdata = b:get()
b = nil
collectgarbage()
print("DIPLOMA:", #bdata)
local ok, share = pcall(function() return require "Share" end)
if ok then
-- Analytics("diploma_share")
share.share("image/jpeg", bdata)
end
</syntaxhighlight>
</syntaxhighlight>
=== <translate>Parameters</translate> ===
'''mimeType''': (string) <translate>The MIME type of the data. </translate> <br/>
'''data''': (string) <translate>The data itself. </translate> <br/>


{{Share}}
{{Share}}

Revision as of 16:25, 18 February 2025

Available since: Gideros 2020.7
Class: Share

Description

Share a piece of data with an external app. This invokes the platform default sharing dialog, allowing to save, print, send, share, etc.

Share.share(mimeType,data)

Supported MIME types:

  • "text/*"
  • "image/png"
  • "image/jpeg"

Parameters

mimeType: (string) the MIME type of the data
data: (string) the data itself

Example

local b = Buffer.new("diploma.jpg")
rt:save("|B|diploma.jpg")
local bdata = b:get()
b = nil
collectgarbage()
print("DIPLOMA:", #bdata)
local ok, share = pcall(function() return require "Share" end)
if ok then
--	Analytics("diploma_share")
	share.share("image/jpeg", bdata)
end