/**
  * Creates an UploadMultipartPart command from an UploadPart object
  *
  * @param UploadPart $part          UploadPart for which to create a command
  * @param bool       $useSourceCopy Whether or not to use the original source or a copy of it
  *
  * @return OperationCommand
  */
 protected function getCommandForPart(UploadPart $part, $useSourceCopy = false)
 {
     // Setup the command with identifying parameters (accountId, vaultName, and uploadId)
     /** @var $command OperationCommand */
     $command = $this->client->getCommand('UploadMultipartPart', $this->state->getUploadId()->toParams());
     $command->set(Ua::OPTION, Ua::MULTIPART_UPLOAD);
     // Get the correct source
     $source = $this->source;
     if ($useSourceCopy) {
         $sourceUri = $this->source->getUri();
         $source = new EntityBody(fopen($sourceUri, 'r'));
     }
     // Add the range, checksum, and the body limited by the range
     $command->set('range', $part->getFormattedRange());
     $command->set('checksum', $part->getChecksum());
     $command->set('ContentSHA256', $part->getContentHash());
     $command->set('body', new ReadLimitEntityBody($source, $part->getSize(), $part->getOffset()));
     return $command;
 }
 /**
  * Updated the upload helper running totals and tree hash with the data from a complete upload part
  *
  * @param UploadPart $part The newly completed upload part
  *
  * @throws OverflowException if the maximum number of allowed upload parts is exceeded
  */
 protected function updateTotals(UploadPart $part)
 {
     // Throw an exception if there are more parts than total allowed
     if ($part->getPartNumber() > self::MAX_NUM_PARTS) {
         // @codeCoverageIgnoreStart
         throw new OverflowException('An archive must be uploaded in ' . self::MAX_NUM_PARTS . ' parts or less.');
         // @codeCoverageIgnoreEnd
     }
     $this->uploadParts[] = $part;
     $this->archiveSize += $part->getSize();
 }