本文整理了Java中com.google.cloud.storage.Blob.<init>()
方法的一些代码示例,展示了Blob.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.<init>()
方法的具体详情如下:
包路径:com.google.cloud.storage.Blob
类名称:Blob
方法名:<init>
暂无
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Blob build() {
return new Blob(storage, infoBuilder);
}
}
代码示例来源:origin: googleapis/google-cloud-java
static Blob fromPb(Storage storage, StorageObject storageObject) {
BlobInfo info = BlobInfo.fromPb(storageObject);
return new Blob(storage, new BlobInfo.BuilderImpl(info));
}
}
代码示例来源:origin: googleapis/google-cloud-java
private void initializeExpectedBlob(int optionsCalls) {
expect(serviceMockReturnsOptions.getOptions()).andReturn(mockOptions).times(optionsCalls);
replay(serviceMockReturnsOptions);
expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(BLOB_INFO));
}
代码示例来源:origin: googleapis/google-cloud-java
private void initializeBlob() {
blob = new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateFromStreamNoContentType() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder("b", "n").build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
InputStream streamContent = new ByteArrayInputStream(content);
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, streamContent)).andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob = bucket.create("n", streamContent);
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateNoContentType() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder("b", "n").build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, content)).andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob = bucket.create("n", content);
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateFromStream() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder("b", "n").setContentType(CONTENT_TYPE).build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
InputStream streamContent = new ByteArrayInputStream(content);
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, streamContent)).andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob = bucket.create("n", streamContent, CONTENT_TYPE);
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testToBuilder() {
expect(storage.getOptions()).andReturn(mockOptions).times(6);
replay(storage);
Blob fullBlob = new Blob(storage, new BlobInfo.BuilderImpl(FULL_BLOB_INFO));
assertEquals(fullBlob, fullBlob.toBuilder().build());
Blob simpleBlob = new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO));
assertEquals(simpleBlob, simpleBlob.toBuilder().build());
Blob directory = new Blob(storage, new BlobInfo.BuilderImpl(DIRECTORY_INFO));
assertEquals(directory, directory.toBuilder().build());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreate() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder("b", "n").setContentType(CONTENT_TYPE).build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, content)).andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob = bucket.create("n", content, CONTENT_TYPE);
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
private void initializeExpectedBucket(int optionsCalls) {
expect(serviceMockReturnsOptions.getOptions()).andReturn(mockOptions).times(optionsCalls);
replay(serviceMockReturnsOptions);
expectedBucket = new Bucket(serviceMockReturnsOptions, new BucketInfo.BuilderImpl(BUCKET_INFO));
blobResults =
ImmutableList.of(
new Blob(
serviceMockReturnsOptions,
new BlobInfo.BuilderImpl(BlobInfo.newBuilder("b", "n1").build())),
new Blob(
serviceMockReturnsOptions,
new BlobInfo.BuilderImpl(BlobInfo.newBuilder("b", "n2").build())),
new Blob(
serviceMockReturnsOptions,
new BlobInfo.BuilderImpl(BlobInfo.newBuilder("b", "n3").build())));
}
代码示例来源:origin: googleapis/google-cloud-java
@Before
public void setUp() {
rpcFactoryMock = createMock(StorageRpcFactory.class);
storageRpcMock = createMock(StorageRpc.class);
expect(rpcFactoryMock.create(anyObject(StorageOptions.class))).andReturn(storageRpcMock);
replay(rpcFactoryMock);
options =
StorageOptions.newBuilder()
.setProjectId("projectid")
.setServiceRpcFactory(rpcFactoryMock)
.setRetrySettings(ServiceOptions.getNoRetrySettings())
.build();
result = new Blob(options.getService(), new BlobInfo.BuilderImpl(RESULT_INFO));
}
代码示例来源:origin: googleapis/google-cloud-java
private void initializeServiceDependentObjects() {
expectedBlob1 = new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1));
expectedBlob2 = new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO2));
expectedBlob3 = new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO3));
expectedBucket1 = new Bucket(storage, new BucketInfo.BuilderImpl(BUCKET_INFO1));
expectedBucket2 = new Bucket(storage, new BucketInfo.BuilderImpl(BUCKET_INFO2));
expectedBucket3 = new Bucket(storage, new BucketInfo.BuilderImpl(BUCKET_INFO3));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testUpdate() throws Exception {
initializeExpectedBlob(2);
Blob expectedUpdatedBlob = expectedBlob.toBuilder().setCacheControl("c").build();
expect(storage.getOptions()).andReturn(mockOptions).times(2);
expect(storage.update(eq(expectedUpdatedBlob), new Storage.BlobTargetOption[0]))
.andReturn(expectedUpdatedBlob);
replay(storage);
initializeBlob();
Blob updatedBlob = new Blob(storage, new BlobInfo.BuilderImpl(expectedUpdatedBlob));
Blob actualUpdatedBlob = updatedBlob.update();
assertEquals(expectedUpdatedBlob, actualUpdatedBlob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testGet() throws Exception {
initializeExpectedBucket(5);
Blob expectedBlob =
new Blob(
serviceMockReturnsOptions,
new BlobInfo.BuilderImpl(BlobInfo.newBuilder("b", "n").build()));
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.get(BlobId.of(expectedBucket.getName(), "n"), new Storage.BlobGetOption[0]))
.andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob = bucket.get("n");
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateFromStreamWithEncryptionKey() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder(BlobId.of("b", "n")).setContentType(CONTENT_TYPE).build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
InputStream streamContent = new ByteArrayInputStream(content);
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, streamContent, Storage.BlobWriteOption.encryptionKey(KEY)))
.andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob =
bucket.create("n", streamContent, CONTENT_TYPE, Bucket.BlobWriteOption.encryptionKey(KEY));
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testUpdateBlob() {
BlobInfo updatedBlobInfo = BLOB_INFO1.toBuilder().setContentType("some-content-type").build();
EasyMock.expect(storageRpcMock.patch(updatedBlobInfo.toPb(), EMPTY_RPC_OPTIONS))
.andReturn(updatedBlobInfo.toPb());
EasyMock.replay(storageRpcMock);
initializeService();
Blob blob = storage.update(updatedBlobInfo);
assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(updatedBlobInfo)), blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testUpdateBlobWithOptions() {
BlobInfo updatedBlobInfo = BLOB_INFO1.toBuilder().setContentType("some-content-type").build();
EasyMock.expect(storageRpcMock.patch(updatedBlobInfo.toPb(), BLOB_TARGET_OPTIONS_UPDATE))
.andReturn(updatedBlobInfo.toPb());
EasyMock.replay(storageRpcMock);
initializeService();
Blob blob =
storage.update(updatedBlobInfo, BLOB_TARGET_METAGENERATION, BLOB_TARGET_PREDEFINED_ACL);
assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(updatedBlobInfo)), blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateNotExists() throws Exception {
initializeExpectedBucket(5);
BlobInfo info =
BlobInfo.newBuilder(BlobId.of("b", "n", 0L)).setContentType(CONTENT_TYPE).build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, content, Storage.BlobTargetOption.generationMatch()))
.andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob = bucket.create("n", content, CONTENT_TYPE, Bucket.BlobTargetOption.doesNotExist());
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateWithEncryptionKey() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder(BlobId.of("b", "n")).setContentType(CONTENT_TYPE).build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, content, Storage.BlobTargetOption.encryptionKey(KEY)))
.andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob =
bucket.create("n", content, CONTENT_TYPE, Bucket.BlobTargetOption.encryptionKey(KEY));
assertEquals(expectedBlob, blob);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateWithKmsKeyName() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder(BlobId.of("b", "n")).setContentType(CONTENT_TYPE).build();
Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info));
byte[] content = {0xD, 0xE, 0xA, 0xD};
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.create(info, content, Storage.BlobTargetOption.kmsKeyName(DEFAULT_KMS_KEY_NAME)))
.andReturn(expectedBlob);
replay(storage);
initializeBucket();
Blob blob =
bucket.create(
"n", content, CONTENT_TYPE, Bucket.BlobTargetOption.kmsKeyName(DEFAULT_KMS_KEY_NAME));
assertEquals(expectedBlob, blob);
}
内容来源于网络,如有侵权,请联系作者删除!