@labkey/api
    Preparing search index...

    Class Data

    The Exp.Data class describes the data input or output of a Run. This typically corresponds to an assay results file uploaded to the LabKey server. To create an Exp.Data object, upload a file using to the "assayFileUpload" action of the "assay" controller.

    To perform a file upload over HTTP:

    <form>
    <input name="example-file-input" type="file" />
    </form>
    <script type="application/javascript">
    LABKEY.Utils.onReady(function() {
    function uploadAssayFile(file) {
    const form = new FormData();
    form.set('file', file);

    LABKEY.Ajax.request({
    url: LABKEY.ActionURL.buildURL('assay', 'assayFileUpload'),
    form: form,
    method: 'POST',
    success: function(response) {
    const data = JSON.parse(response.responseText);
    var expData = new LABKEY.Exp.Data(data);

    // now add the data as a dataInput to a LABKEY.Exp.Run
    var run = new LABKEY.Exp.Run();
    run.name = expData.name;
    run.dataInputs = [ expData ];

    // add the new run to a LABKEY.Exp.Batch object here
    },
    });
    }

    function onFileChange(event) {
    const file = event.target.files[0];
    uploadAssayFile(file);
    }

    const input = document.querySelector('input[name="example-file-input"]');
    input.addEventListener('change', onFileChange);
    });
    </script>

    Or, to upload the contents of a JavaScript string as a file:

    LABKEY.Ajax.request({
    url: LABKEY.ActionURL.buildURL('assay', 'assayFileUpload'),
    params: { fileName: 'test.txt', fileContent: 'Some text!' },
    method: 'POST',
    success: function (response) {
    const data = JSON.parse(response.responseText);
    var expData = new LABKEY.Exp.Data(data);

    // now add the data as a dataInput to a LABKEY.Exp.Run
    var run = new LABKEY.Exp.Run();
    run.name = expData.name;
    run.dataInputs = [ expData ];

    // add the new run to a LABKEY.Exp.Batch object here
    },
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    comment: string

    User editable comment.

    created: Date

    The person who created the ExpObject.

    createdBy: string

    The person who created the ExpObject.

    dataClass: ExpDataDataClass

    The DataClass the data belongs to.

    dataFileURL: string

    The local file url of the uploaded file.

    dataType: string

    TODO: Describe dataType. Possibly no longer supported.

    id: number

    The id of the ExpObject

    lsid: string

    The LSID of the ExpObject

    modified: Date

    When the ExpObject was last modified.

    modifiedBy: string

    The person who last modified the ExpObject.

    name: string

    The name of the ExpObject

    pipelinePath: string

    Path relative to pipeline root.

    properties: Record<string, any>

    Map of property descriptor names to values. Most types, such as strings and numbers, are just stored as simple properties. Properties of type FileLink will be returned by the server in the same format as Data objects (missing many properties such as id and createdBy if they exist on disk but have no row with metadata in the database). FileLink values are accepted from the client in the same way, or a simple value of the following three types: the data's RowId, the data's LSID, or the full path on the server's file system.

    role: string

    The role designation for this data.

    rowId: number

    The id of the ExpObject (alias of id property)

    Methods

    • Retrieves the contents of the data object from the server.

      Parameters

      • options: IGetContentOptions

        An example of the results for a request for 'jsonTsv' format:

        {
        "filename": "SimpleExcelFile.xls",
        "sheets": [
        {
        "name": "Sheet1",
        "data": [
        ["StringColumn", "DateColumn"],
        ["Hello", "16 May 2009 17:00:00"],
        ["world", "12/21/2008 08:45AM"]
        ]
        },{
        "name": "Sheet2",
        "data": [
        ["NumberColumn"],
        [55.44],
        [100.34],
        [-1]
        ]
        },{
        "name": "Sheet3",
        "data": []
        }
        ]
        }

        An example of the same file in the 'jsonTSVExtended' format:

        {
        "filename": "SimpleExcelFile.xls",
        "sheets": [
        {
        "name": "Sheet1",
        "data": [[
        {
        "value": "StringColumn",
        "formattedValue": "StringColumn"
        },{
        "value": "DateColumn",
        "formattedValue": "DateColumn"
        }
        ],[
        {
        "value": "Hello",
        "formattedValue": "Hello"
        },{
        "formatString": "MMMM d, yyyy",
        "value": "16 May 2009 17:00:00",
        "timeOnly": false,
        "formattedValue": "May 17, 2009"
        }
        ],[
        {
        "value": "world",
        "formattedValue": "world"
        },{
        "formatString": "M/d/yy h:mm a",
        "value": "21 Dec 2008 19:31:00",
        "timeOnly": false,
        "formattedValue": "12/21/08 7:31 PM"
        }
        ]]
        },{
        "name": "Sheet2",
        "data": [
        [{
        "value": "NumberColumn",
        "formattedValue": "NumberColumn"
        }],[{
        "formatString": "$#,##0.00",
        "value": 55.44,
        "formattedValue": "$55.44"
        }],[{
        "value": 100.34,
        "formattedValue": "100.34"
        }],[{
        "value": -1,
        "formattedValue": "-1"
        }]
        ]
        },{
        "name": "Sheet3",
        "data": []
        }
        ]
        }

      Returns void