@Override
  public boolean archive(String gcsUrl, byte[] data) {
    BlobInfo blobInfo = parseBlobInfo(gcsUrl);

    if (data.length <= options.chunkUploadThresholdInBytes) {
      // Create the blob in one request.
      logger.atInfo().log("Archiving data to GCS at '%s' in one request.", gcsUrl);
      storage.create(blobInfo, data);
      return true;
    }

    // When content is large (1MB or more) it is recommended to write it in chunks via the blob's
    // channel writer.
    logger.atInfo().log(
        "Content is larger than threshold, archiving data to GCS at '%s' in chunks.", gcsUrl);
    try (WriteChannel writer = storage.writer(blobInfo)) {
      for (int chunkOffset = 0;
          chunkOffset < data.length;
          chunkOffset += options.chunkSizeInBytes) {
        int chunkSize = Math.min(data.length - chunkOffset, options.chunkSizeInBytes);
        writer.write(ByteBuffer.wrap(data, chunkOffset, chunkSize));
      }
      return true;
    } catch (IOException e) {
      logger.atSevere().withCause(e).log("Unable to archving data to GCS at '%s'.", gcsUrl);
      return false;
    }
  }
@Test
  public void archive_withSmallSizeString_createsBlobInOneRequest() {
    GoogleCloudStorageArchiver archiver = archiverFactory.create(mockStorage);
    String dataToArchive = "TEST DATA";

    boolean succeeded = archiver.archive(buildGcsUrl(BUCKET_ID, OBJECT_ID), dataToArchive);

    assertThat(succeeded).isTrue();
    verify(mockStorage, times(1)).create(blobInfoCaptor.capture(), byteDataCaptor.capture());
    assertThat(blobInfoCaptor.getValue())
        .isEqualTo(BlobInfo.newBuilder(BUCKET_ID, OBJECT_ID).build());
    assertThat(byteDataCaptor.getValue()).isEqualTo(dataToArchive.getBytes(UTF_8));
  }