public function __construct(Configuration $configuration, $accountId)
 {
     $this->configuration = $configuration;
     $storageApi = $this->configuration->getStorageApi();
     $sysBucket = $this->configuration->getSysBucketId();
     $this->accountId = $accountId;
     parent::__construct($storageApi, $sysBucket . '.' . $accountId);
 }
 public function save($data, Sheet $sheet)
 {
     $sheetConfig = $sheet->getConfig();
     $tmpFilename = $this->writeRawCsv($data, $sheet);
     $dataProcessor = new DataProcessor($tmpFilename, $sheetConfig);
     $outFilename = $dataProcessor->process();
     $this->configuration->initDataBucket($sheetConfig['db']['table']);
     $outputTable = $sheetConfig['db']['table'];
     $tableNameArr = explode('.', $outputTable);
     if (count($tableNameArr) != 3) {
         throw new UserException(sprintf("Error in configuration. Wrong tableId format '%s'", $outputTable));
     }
     $table = new Table($this->configuration->getStorageApi(), $outputTable, $outFilename);
     try {
         $table->save(true);
     } catch (ClientException $e) {
         throw new UserException($e->getMessage(), $e, ['outputTable' => $outputTable, 'sheet' => $sheet->toArray()]);
     }
     unlink($tmpFilename);
 }