Skip to content

Files Export

asaweero edited this page Aug 22, 2017 · 3 revisions

Exports a file for a given record, field, and event. Currently, the file can only be exported to the root directory of the redcap.js module.

Required Parameters

  • record: The record of the file you want to export.
  • field: The name of the field where the file is saved.
  • event: (Only for longitudinal projects, leave as a blank string otherwise) The unique event name.
  • repeat_instance: (Only for projects with repeating instruments or events) The repeat instance number of the repeating event/instrument. The default value is 1.

Return Value

  • Return the contents of the file

Method Usage

    var params = {
      record: '1',
      field: 'testfile',
      event: 'event_1_arm_1',
      directory: '',
      repeat_instance: ''
    };

    redcap.files.export (params, function (err, res) {
      // error containts oprtional errors
      if (err) {
          // handle error
      }
      else {
          // res is return value
          console.log (res);
      }
    });