How to use the react-native-unimodules.FileSystem.getInfoAsync function in react-native-unimodules

To help you get started, we’ve selected a few react-native-unimodules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github acrcloud / webapi_example / identify protocol 1 (recommended) / reactnative_ios.js View on Github external
async function identify(uri, options) {
  var current_data = new Date();
  var timestamp = current_data.getTime() / 1000;
  var stringToSign = buildStringToSign(
    'POST',
    options.endpoint,
    options.access_key,
    options.data_type,
    options.signature_version,
    timestamp,
  );
  let fileinfo = await FileSystem.getInfoAsync(uri, {size: true});
  var signature = signString(stringToSign, options.access_secret);
  var formData = {
    sample: {uri: uri, name: 'sample.wav', type: 'audio/wav'},
    access_key: options.access_key,
    data_type: options.data_type,
    signature_version: options.signature_version,
    signature: signature,
    sample_bytes: fileinfo.size,
    timestamp: timestamp,
  };
  var form = new FormData();
  for (let key in formData) {
    form.append(key, formData[key]);
  }

  let postOptions = {