public function upload(array $data)
	{
		$accessToken = $this->client->getAccessToken();

		if (is_null($accessToken))
		{
			throw new \Exception('You need an access token to upload');
		}

		// Attempt to refresh the access token if it's expired and save the new one in the database
		if ($this->client->isAccessTokenExpired())
		{
			$accessToken = json_decode($accessToken);
			$refreshToken = $accessToken->refresh_token;
			$this->client->refreshToken($refreshToken);
			$newAccessToken = $this->client->getAccessToken();
			$this->saveAccessTokenToDB($newAccessToken);
		}

		$snippet = new \Google_Service_YouTube_VideoSnippet();
		if (array_key_exists('title', $data))
		{
			$snippet->setTitle($data['title']);
		}
		if (array_key_exists('description', $data))
		{
			$snippet->setDescription($data['description']);
		}
		if (array_key_exists('tags', $data))
		{
			$snippet->setTags($data['tags']);
		}
		if (array_key_exists('category_id', $data))
		{
			$snippet->setCategoryId($data['category_id']);
		}

		$status = new \Google_Service_YouTube_VideoStatus();
		if (array_key_exists('status', $data))
		{
			$status->privacyStatus = $data['status'];
		}

		$video = new \Google_Service_YouTube_Video();
		$video->setSnippet($snippet);
		$video->setStatus($status);

		$result = $this->youtube->videos->insert(
			'status,snippet',
			$video,
			array(
				'data'       => file_get_contents( $data['video']->getRealPath() ),
				'mimeType'   => $data['video']->getMimeType(),
				'uploadType' => 'multipart'
			)
		);

		if (!($result instanceof \Google_Service_YouTube_Video))
		{
			throw new \Exception('Expecting instance of Google_Service_YouTube_Video, got:' . $result);
		}

		return $result->getId();

	}