public function uploadNewVersion($id, $pathname, $revisionComment, $filename = null, $progress = null, $chunkSize = 10485760)
        {
            $chunk = 0;
            $chunksTotal = ceil(filesize($pathname) / $chunkSize);
            $fileId = sha1(uniqid('uploadVersion', true));
            $filename = $filename ?: pathinfo($filename, PATHINFO_BASENAME);
            $fp = fopen($pathname, 'r');
            if (false === $fp) {
                throw new UploadException('Could not open file "' . $pathname . '" for reading.');
            }
            if ($chunkSize > 10485760) {
                $this->logger->warning('Using a chunk size larger then 10MB is not recommended. Uploading is not guaranteed to work properly.');
            }
            while ($chunkData = fread($fp, $chunkSize)) {
                $result = $this->uploadNewVersionChunked($chunkData, $id, $revisionComment, $filename, $chunk, $chunksTotal, $fileId);
                if (is_callable($progress)) {
                    try {
                        call_user_func($progress, $chunk + 1, $chunksTotal);
                    } catch (\Exception $e) {
                        $this->logger->warning('Could not report progress due to callback error.', ['message' => $e->getMessage()]);
                    }
                }
                $this->logger->info('Upload progress!', ['part' => $chunk + 1, 'total' => $chunksTotal]);
                if (isset($result['mediaId'])) {
                    return new MediaResponse($result);
                }
                if (isset($result['success']) && false == $result['success']) {
                    throw new UploadException($result['error']['message'], $result['error']['code']);
                }
                $fileId = $result['fileId'];
                ++$chunk;
            }
            if ($chunk == $chunksTotal - 1) {
                throw new UploadException('Uploaded all chunks, but something went wrong.');
            }
            if (false === $chunkData) {
                throw new UploadException('Could not read chunk ' . $chunk . ' from file "' . $pathname . '".');
            }
            throw new UploadException('Unknown upload error!');
        }