writecustomasset(path, data)
Writes a file into the workspace and returns an rbxasset:// id for it.
Syntax
writecustomasset(path: string, data: string) -> string
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-relative file path. |
data | string | File contents (for example PNG bytes). |
Returns
| Type | Description |
|---|---|
string | rbxasset:// id that ContentProvider can load. |
Description
Writes the file with the same rules as writefile, copies it into the ExtraContent folder and returns the rbxasset:// URL. The site is the asset id equivalent of getcustomasset for data that is not on disk yet.
The write is synchronous; use writefileasync first if you need to avoid blocking the current frame.
Example
local id = writecustomasset("icon.png", imageBytes)
print(id:find("^rbxasset://") ~= nil)