# SPhotos

## Index

### Functions Index

| Function Name                                                                  |
| ------------------------------------------------------------------------------ |
| SResource [**GetUploadedTexture** ](#getuploadedtexture)()                     |
| void [**GetSavedTexture** ](#getsavedtexture)(string path, Closure onComplete) |
| Table [**GetInventoryTextures** ](#getinventorytextures)()                     |
| void [**OpenUploadFileBrowser** ](#openuploadfilebrowser)()                    |
| void [**OnUploadEnd** ](#onuploadend)(Closure c)                               |
| void [**OnUploadStart** ](#onuploadstart)(Closure c)                           |

## Functions

### GetUploadedTexture

[SResource](https://docs.sine.space/scripting/client-scripting-api-reference/types/sresource) **GetUploadedTexture** ()

*Function Description*

{% tabs %}
{% tab title="Lua" %}

```lua
resourceTexture = Space.Photos.GetUploadedTexture()
```

{% endtab %}
{% endtabs %}

### GetSavedTexture

void **GetSavedTexture** (string path, Closure onComplete)

*Function Description*

| Parameter  | Type               | Description                                                                                        |
| ---------- | ------------------ | -------------------------------------------------------------------------------------------------- |
| path       | string             |                                                                                                    |
| onComplete | Closure (Callback) | <p>Closure will be called once the saved texture has been retrieved.<br>onComplete(SResource) </p> |

{% tabs %}
{% tab title="Lua" %}

```lua
function onComplete(SResource)
resourceTexture = SResource
end

Space.Photos.GetSavedTexture('APath', onComplete)
```

{% endtab %}
{% endtabs %}

### GetInventoryTextures

Table **GetInventoryTextures** ()

*Function Description*

{% tabs %}
{% tab title="Lua" %}

```lua
tableInventoryTexture = Space.Photos.GetInventoryTextures()
```

{% endtab %}
{% endtabs %}

### OpenUploadFileBrowser

void **OpenUploadFileBrowser** ()

*Opens a window that let's you select a file you wish to upload. (white-label)*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Photos.OpenUploadFileBrowser()
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--this script will open a file upload browser when clicked
thisObject = Space.Host.ExecutingObject

function OnClickFunction()
Space.Photos.OpenUploadFileBrowser()
end


thisObject.AddClickable()
thisObject.Clickable.Tooltip = "Click me to upload photo"
thisObject.Clickable.OnClick(OnClickFunction)
```

{% endtab %}
{% endtabs %}

### OnUploadEnd

void **OnUploadEnd** (Closure c)

**Binds the function c to be called when an upload operation ends.**

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
function c()
--
end

Space.Photos.OnUploadEnd(c)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--this script will show a text on screen that says "Uploading..." when a photo upload is initiated
--and will hide it when the upload has ended
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("textObject") --add a UIText object to References in Scripting Runtime
textObject.UIText.Text = "Uploading..."

function OnUploadStartFunction()
textObject.Active = true
end

function OnUploadEndFunction()
textObject.Active = false
end

Space.Photos.OnUploadStart(OnUploadStartFunction)
Space.Photos.OnUploadEnd(OnUploadEndFunction)
```

{% endtab %}
{% endtabs %}

### OnUploadStart

void **OnUploadStart** (Closure c)

*Function Description*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
function c()
--
end

Space.Photos.OnUploadStart(c)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--this script will show a text on screen that says "Uploading..." when a photo upload is initiated
--and will hide it when the upload has ended
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("textObject") --add a UIText object to References in Scripting Runtime
textObject.UIText.Text = "Uploading..."

function OnUploadStartFunction()
textObject.Active = true
end

function OnUploadEndFunction()
textObject.Active = false
end

Space.Photos.OnUploadStart(OnUploadStartFunction)
Space.Photos.OnUploadEnd(OnUploadEndFunction)
```

{% endtab %}
{% endtabs %}
