Upload Assets

24 June 2020

  • C10 - removed extended image file formats in favor of built-in types.

27 May 2017

  • Release 9.164
    • Added optional mono parameter when uploading scripts.
    • The command returns script compilation errors.
    • The command updates inventory assets such as notecards and scripts if they already exist in the inventory.
    • The command now uses the Corrade permission system notation.

13 July 2016

  • Release 9.105 - the command now returns both the inventory item UUID and the asset UUID of the uploaded item (if any).

10 July 2016

  • Relese 9.104 - added extended formats for the Windows platform.

4 May 2015

  • Release 7.82 - Corrade now supports uploading multiple image formats for the Texture asset type.

14 December 2014

  • Release 7.28 - added.
upload (Commands)
TypeCorrade progressive command
Commandupload
DescriptionThe upload command can be used upload assets onto the grid.
Permissionsinventory, economy
Parametersgroup, password, name, type, data
Last ChangesRelease 9.164 - Added optional mono parameter when uploading scripts; The command returns script compilation errors; The command updates inventory assets such as notecards and scripts if they already exist in the inventory; The command now uses the Corrade permission system notation.

The upload command can be used upload assets onto the grid.

Command Required Parameters Required Corrade Permissions Example
upload group, password, name, type, data inventory, economy
llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // Create a script called "Good day!"
            // with the content passed to "data"
            // and set permissions to MODIFY COPY.
            "command", "upload",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "name", "Good day!",
            "type", "LSLText",
            "data", wasURLEscape(llStringToBase64("
                default {
                    state_entry() {
                        llOwnerSay(\"Good day!\");
                    }
                }
            ")),
            // "Copy" and "Modify" permissions.
            "permissions", "c--mvt------------c--mv-c--mvt",
            "callback", wasURLEscape(URL)
        ]
    )
);
Optional Parameter Description
description The description of the asset.
permissions The permissions in Corrade permission system notation for the next owner (this option is ignored for Landmarks which always have full permission).
item If an item by name or inventory path (ex: /My Inventory/Notecards/MyNote) is specified, then that item will be updated and no new item created.
mono When uploading a script, if mono is set to True (by default set to True) then Corrade will use the mono compiler instead of LSO.

The possible and currently supported uploadable assets are the following:

Parameter Possible Value Parameter Description Example
type Texture Uploads a texture that is encoded in either JPEG2000 or one of the other supported formats.
llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // Upload a texture and call it Skull
            "command", "upload",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            // The name as it will appear in the
            // inventory textures folder.
            "name", "Skull",
            "type", "Texture",
            // The Base64-encoded image binary data.
            // (This is a small skull texture in TGA
            // format that has been encoded to Base64)
            "data", wasURLEscape("
                iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAACCEkxzAAAAAnRSTlMAAQGU/a4A
                AADySURBVHgBjdK3lQMhGATgQd6jUBltXCJTikq48LJlnxpDZ9tAHWwow4Mb/t3z
                dqIPb5Ga/AGgEARACyqgLXAABOgHrInIrtYQQbGbJo7seewTLKWY4Q3nbGesiZJw
                BeEyEuOJUlA0qN6j/QHH9XsYYkG0iDjI0N8hLBpEwUQfZwMC87ZvgTNbKK9qwEGw
                cc7ajNLv/TZvdeecYL+zbiuwykPg2hU8Ufr+UeWtKt8P7Srv8Di/08c1eBFVOwkO
                VfsgsNdte8M+wNUTIDCxXh06AHnRiQ4TRRxXOpg+kSKR/g3lGwBrQXqFRVHDqVQj
                mN//xjODplxESg0eZQAAAABJRU5ErkJggg==
            "),
            "callback", wasURLEscape(URL)
        ]
    )
);
Sound Uploads a sound in OGG Vorbis format.
Animation Uploads an animation in .animatn format.
Clothing wear Uploads wearables for a certain clothing slot (wear) set to one of the values of the WearableType enumeration.
Bodypart wear Uploads body parts for a certain slot (wear) set to one of the values of the WearableType enumeration.
Landmark Uploads landmarks.
Gesture Uploads gestures.
Notecard Uploads notecards.
LSLText Uploads scripts.

and the data passed to the data parameter is compatible with the data retrieved by the download command.

Supported Texture Image Formats

Grid clients such as Corrade download and upload textures to the grid in the JPEG2000 image format. The upload of textures in different formats other than JPEG2000 is provided as a convenience but Linden grids can only accept JPEG2000 images. In other words, regardless of the image format that you want to upload, Corrade will have to convert the image to the JPEG2000 format (with lossless compression) and only then upload it. You may want to rethink your application in case you really depend on some format provided here and convert your images to JPEG2000 yourself before uploading. For instance, under Windows, uploading a 24-bit PNG is meaningless from Corrade's perspective because the grid does not accept such a format (only JPEG2000) such that the 24-bit PNG will be first converted to JPEG2000 and then uploaded.

A counter-example when using any other format other than JPEG2000 is useful when you need to upload or download an image from PHP (or other environments) that do not have built-in support for the JPEG2000 image format. In such cases, in order to not over-complicate your script, you can use the formats listed here depending on your platform. However, as mentioned previously, be weary because grid clients can only upload textures in the JPEG2000 format such that you could probably convert your image to JPEG2000 better than having Corrade do it for you.

The supported image formats are the following:

Format Parameter Value Description
Bmp Windows Bitmap
Gif Graphics Interchange Format
Jpeg JPEG File Exchange Format - this is not JPEG2000
Png Portable Network Graphics
Tiff Tagged Image File Format

Omitting the format parameter will result in a JPEG2000 image to be downloaded directly off the asset server. The JPEG2000 image format is defined with various profiles, such that if the downloaded image is saved to a file and then inspected by the file or exiftool command line utilities, the detected image description will be:

JPEG2000 codestream

which indicates a Profile 0 JPEG2000 which is what the SecondLife grid seems to be using. Profile 0 (subset of 1, 2) was probably chosen to maximize compatibility with tools that have not yet implemented full support for JPEG2000.

The proper file extension for such images is "j2c" which stands for JPEG2000 codestream. Some tools may not properly implement nor respect the file extension. For instance, using ffmpeg to convert an image to JPEG2000 codestream:

ffmpeg -i img.png img.j2c

will result in a Profile 1 JPEG2000 instead of a JPEG2000 Profile 0 codestream such that it is imperative to make sure that the proper tools are used when downloading or uploading images.

Furthermore, Corrade follows the SecondLife limits on texture uploads without any processing such that the user must ensure that the texture to be uploaded conforms to the specification.

2021/05/26 06:23

Supported Sound Formats

Corrade uploads OGG Vorbis files with the same specification that is listed on the official wiki. In case the uploaded sound seems distorted please check that all the parameters have been met. Typically, the audio rate is the culprit for most sound distortions and one must make sure that the rate of the file to be uploaded is $44100Hz$.

Encoding Assets for Upload

For example, to upload a texture, you would have to have an image encoded in one of the supported image formats. For this example, let's assume you have a JPEG2000 image. You would Base64-encode the JPEG2000 code-stream image. After that, you send the upload command to Corrade with the value of the data key set to an URL-encoded string of the Base64-encoded JPEG2000 code-stream image.

In other words:

  • you have an initial JPEG2000 code-stream image file.
  • you encode the image file as a Base64 string.
  • you encode the Base64 string in an URL-encoded string.

The reason for multiple levels of encoding is that Base64 uses the equal sign (=) as a padding element which interferes with key-value data syntax.

Since Base64 encoding may produce large strings, a reliable way to upload assets is to use Corrade's internal HTTP server instead of writing large strings in LSL.

Assets such as clothing, landmarks, gestures, notecards and scripts can be uploaded (created) as the reverse operation of the download command. Each of these assets are Linden-based formats which, some of them, can be reconstructed intuitively in plain-text. For example, scripts as LSLText requires the encoded data to be just a plain-text LSL script. Landmarks, clothing, gestures and notecards also have their own specific Linden-based format. If you are curious to see what that format may be, use the download command on some clothing and then Base64 decode the data returned by Corrade.

Returned Data

Under the assumption that the upload succeeded, Corrade will return a CSV list of item UUID by asset UUID (if any) that can then be used for other commands in order to refer to the asset that has been uploaded. Additionally, if the asset was a script and the script failed to compile, then the command will return the script compilation errors.


secondlife/scripted_agents/corrade/api/commands/upload.txt ยท Last modified: 2023/07/21 10:39 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.