|
27 | 27 | import com.google.cloud.storage.Storage.BlobSourceOption;
|
28 | 28 | import com.google.cloud.storage.Storage.BlobWriteOption;
|
29 | 29 | import com.google.cloud.storage.StorageException;
|
| 30 | +import com.google.cloud.storage.StorageOptions; |
30 | 31 | import com.google.cloud.storage.TestUtils;
|
31 | 32 | import com.google.cloud.storage.TmpFile;
|
32 | 33 | import com.google.cloud.storage.TransportCompatibility.Transport;
|
|
48 | 49 | import com.google.common.collect.ImmutableList;
|
49 | 50 | import java.io.IOException;
|
50 | 51 | import java.nio.ByteBuffer;
|
| 52 | +import java.nio.channels.SeekableByteChannel; |
51 | 53 | import java.nio.file.Files;
|
52 | 54 | import java.nio.file.NoSuchFileException;
|
53 | 55 | import java.nio.file.Path;
|
54 | 56 | import java.nio.file.Paths;
|
| 57 | +import java.nio.file.StandardOpenOption; |
55 | 58 | import java.util.ArrayList;
|
56 | 59 | import java.util.Collections;
|
57 | 60 | import java.util.Comparator;
|
58 | 61 | import java.util.List;
|
| 62 | +import java.util.UUID; |
59 | 63 | import java.util.stream.Collectors;
|
60 | 64 | import org.junit.Before;
|
61 | 65 | import org.junit.Rule;
|
@@ -378,8 +382,10 @@ public void uploadFilesAllowMultiplePCUAndSmallerFiles() throws Exception {
|
378 | 382 | TmpFile tmpFile = DataGenerator.base64Characters().tempFile(baseDir, largeFileSize);
|
379 | 383 | TmpFile tmpfile2 = DataGenerator.base64Characters().tempFile(baseDir, largeFileSize);
|
380 | 384 | TmpFile tmpFile3 = DataGenerator.base64Characters().tempFile(baseDir, smallFileSize)) {
|
| 385 | + List<Storage.BlobWriteOption> writeOptsPerRequest = new ArrayList<>(); |
| 386 | + writeOptsPerRequest.add(Storage.BlobWriteOption.disableGzipContent()); |
381 | 387 | ParallelUploadConfig parallelUploadConfig =
|
382 |
| - ParallelUploadConfig.newBuilder().setBucketName(bucket.getName()).build(); |
| 388 | + ParallelUploadConfig.newBuilder().setBucketName(bucket.getName()).setWriteOptsPerRequest(writeOptsPerRequest).build(); |
383 | 389 | List<Path> files =
|
384 | 390 | ImmutableList.of(tmpFile.getPath(), tmpfile2.getPath(), tmpFile3.getPath());
|
385 | 391 | UploadJob job = transferManager.uploadFiles(files, parallelUploadConfig);
|
@@ -502,6 +508,34 @@ public void downloadBlobsOneFailure() throws Exception {
|
502 | 508 | }
|
503 | 509 | }
|
504 | 510 |
|
| 511 | + @Test |
| 512 | + public void testpcu() throws Exception{ |
| 513 | + String PREFIX = "prefix"; |
| 514 | + |
| 515 | + /** Will create a large local file at this path. */ |
| 516 | + String TMP_PATH = "/tmp/"; |
| 517 | + |
| 518 | + TmpFile tmpFile = DataGenerator.base64Characters().tempFile(Paths.get(TMP_PATH), 4L * 1024L * 1024L * 1024L - 1); |
| 519 | + StorageOptions options = StorageOptions.newBuilder().build(); |
| 520 | + TransferManagerConfig tmc = TransferManagerConfig.newBuilder() |
| 521 | + .setAllowParallelCompositeUpload(true).build(); |
| 522 | + try (TransferManager tm = tmc.getService()) { |
| 523 | + List<Path> files = new ArrayList<>(); |
| 524 | + files.add(tmpFile.getPath()); |
| 525 | + List<Storage.BlobWriteOption> writeOptsPerRequest = new ArrayList<>(); |
| 526 | + writeOptsPerRequest.add(Storage.BlobWriteOption.disableGzipContent()); |
| 527 | + System.out.println( |
| 528 | + tm.uploadFiles( |
| 529 | + files, |
| 530 | + ParallelUploadConfig.newBuilder() |
| 531 | + .setBucketName(bucket.getName()) |
| 532 | + .setPrefix(PREFIX) |
| 533 | + .setWriteOptsPerRequest(writeOptsPerRequest) |
| 534 | + .build()) |
| 535 | + .getUploadResults()); |
| 536 | + } |
| 537 | + } |
| 538 | + |
505 | 539 | private void cleanUpFiles(List<DownloadResult> results) throws IOException {
|
506 | 540 | // Cleanup downloaded blobs and the parent directory
|
507 | 541 | for (DownloadResult res : results) {
|
|
0 commit comments