/** * Initiates the upload procedure. * * @return \Guzzle\Http\Message\Response * @throws RuntimeException If the transfer is not in a "running" state * @throws UploadException If any errors occur during the upload * @codeCoverageIgnore */ public function upload() { if (!$this->transferState->isRunning()) { throw new RuntimeException('The transfer has been aborted.'); } try { $this->transfer(); $response = $this->createManifest(); } catch (Exception $e) { throw new UploadException($this->transferState, $e); } return $response; }
/** * Build the transfer. * * @return mixed * @throws \OpenCloud\Common\Exceptions\InvalidArgumentError */ public function build() { // Validate properties if (!$this->container || !$this->entityBody || !$this->options['objectName']) { throw new InvalidArgumentError('A container, entity body and object name must be set'); } // Create TransferState object for later use $transferState = TransferState::factory(); // Instantiate Concurrent-/ConsecutiveTransfer $transferClass = isset($this->options['concurrency']) && $this->options['concurrency'] > 1 ? __NAMESPACE__ . '\\ConcurrentTransfer' : __NAMESPACE__ . '\\ConsecutiveTransfer'; return $transferClass::newInstance()->setClient($this->container->getClient())->setEntityBody($this->entityBody)->setTransferState($transferState)->setOptions($this->options)->setOption('containerName', $this->container->getName())->setOption('containerUrl', $this->container->getUrl())->setup(); }