Java源码示例:io.minio.errors.NoResponseException

示例1
@Override
public FileEntity getAuthFileContent(String name) throws IOException {

    try {
        ObjectStat stat = minioClient.statObject(minioConfig.getAuthBucket(), name);
        InputStream inputStream = minioClient.getObject(minioConfig.getAuthBucket(), name);

        FileEntity file = new FileEntity();
        file.setLength(stat.length());
        file.setFileName(stat.name()); // TODO 可以通过httpHeaders来处理文件上传时的文件名
        file.setContentType(stat.contentType());
        file.setContent(inputStream);
        return file;

    } catch (InvalidKeyException | InvalidBucketNameException | NoSuchAlgorithmException | NoResponseException
            | ErrorResponseException | InternalException | InvalidArgumentException | InsufficientDataException
            | InvalidResponseException | XmlPullParserException e) {
        throw new IOException(e);
    }
}
 
示例2
/**
 * retrieve archive from storage
 *
 * @param archiveEntry
 * @return
 */
public byte[] getArchive(ArchiveEntry archiveEntry)
{
	String hashStr = BaseEncoding.base16().encode(archiveEntry.getHash());
	String path = new StringBuilder()
		.append(hashStr, 0, 2)
		.append('/')
		.append(hashStr.substring(2))
		.toString();

	try (InputStream in = minioClient.getObject(minioBucket, path))
	{
		return ByteStreams.toByteArray(in);
	}
	catch (InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException
		| IOException | InvalidKeyException | NoResponseException | XmlPullParserException
		| ErrorResponseException | InternalException | InvalidArgumentException ex)
	{
		log.warn(null, ex);
		return null;
	}
}
 
示例3
@Override
public InputStream getAuthImage(String objectName) throws IOException {
    String bucketName = minioConfig.getAuthBucket();
    try {
        return minioClient.getObject(bucketName, objectName);
    } catch (InvalidKeyException | InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException
            | NoResponseException | ErrorResponseException | InternalException | InvalidArgumentException
            | InvalidResponseException | XmlPullParserException e) {
        throw new IOException(e);
    }
}
 
示例4
@Override
public String getAuthFile(String objectName, Integer expires) throws IOException {
    try {
        return minioClient.getPresignedObjectUrl(Method.GET, minioConfig.getAuthBucket(), objectName, expires,
                null);
    } catch (InvalidKeyException | InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException
            | NoResponseException | ErrorResponseException | InternalException | InvalidExpiresRangeException
            | InvalidResponseException | XmlPullParserException e) {
        throw new IOException(e);
    }
}
 
示例5
/** @see MinioClient#putObject(String, String, InputStream, String) */
void putObject(String objectName, InputStream stream, String contentType)
    throws InvalidBucketNameException, NoSuchAlgorithmException, IOException, InvalidKeyException,
        NoResponseException, XmlPullParserException, ErrorResponseException, InternalException,
        InvalidArgumentException, InsufficientDataException {
  LOG.trace("Putting object '{}' in bucket '{}' ...", objectName, bucketName);
  minioClient.putObject(bucketName, objectName, stream, contentType);
  LOG.debug("Put object '{}' in bucket '{}'", objectName, bucketName);
}
 
示例6
/** @see MinioClient#statObject(String, String) */
ObjectStat statObject(String objectName)
    throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException,
        IOException, InvalidKeyException, NoResponseException, XmlPullParserException,
        ErrorResponseException, InternalException {
  LOG.trace("Retrieving metadata for object '{}' in bucket '{}' ...", objectName, bucketName);
  ObjectStat objectStat = minioClient.statObject(bucketName, objectName);
  LOG.debug("Retrieved metadata for object '{}' in bucket '{}'", objectName, bucketName);
  return objectStat;
}
 
示例7
/** @see MinioClient#removeObject(String, String) */
void removeObject(String objectName)
    throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException,
        IOException, InvalidKeyException, NoResponseException, XmlPullParserException,
        ErrorResponseException, InternalException, InvalidArgumentException {
  LOG.trace("Removing object '{}' in bucket '{}' ...", objectName, bucketName);
  minioClient.removeObject(bucketName, objectName);
  LOG.debug("Removed object '{}' in bucket '{}'", objectName, bucketName);
}
 
示例8
/** @see io.minio.MinioClient#getObject(java.lang.String, java.lang.String) */
InputStream getObject(String objectName)
    throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException,
        IOException, InvalidKeyException, NoResponseException, XmlPullParserException,
        ErrorResponseException, InternalException, InvalidArgumentException {
  LOG.trace("Streaming object '{}' in bucket '{}' ...", objectName, bucketName);
  return minioClient.getObject(bucketName, objectName);
}
 
示例9
@Test
void testPutObject()
    throws IOException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException,
        InvalidArgumentException, InternalException, NoResponseException,
        InvalidBucketNameException, InsufficientDataException, ErrorResponseException {
  String objectName = "MyObjectName";
  InputStream inputStream = mock(InputStream.class);
  String contentType = "application/octet-stream";
  minioClientFacade.putObject(objectName, inputStream, contentType);
  verify(minioClient).putObject(bucketName, objectName, inputStream, contentType);
}
 
示例10
@Test
void testStatObject()
    throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException,
        InternalException, NoResponseException, InvalidBucketNameException,
        XmlPullParserException, ErrorResponseException {
  String objectName = "MyObjectName";
  ObjectStat objectStat = mock(ObjectStat.class);
  when(minioClient.statObject(bucketName, objectName)).thenReturn(objectStat);
  assertEquals(objectStat, minioClientFacade.statObject(objectName));
}
 
示例11
@Test
void testRemoveObject()
    throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException,
        InvalidArgumentException, InternalException, NoResponseException,
        InvalidBucketNameException, XmlPullParserException, ErrorResponseException {
  String objectName = "MyObjectName";
  minioClientFacade.removeObject(objectName);
  verify(minioClient).removeObject(bucketName, objectName);
}
 
示例12
@Test
void testGetObject()
    throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException,
        InvalidArgumentException, InternalException, NoResponseException,
        InvalidBucketNameException, XmlPullParserException, ErrorResponseException {
  String objectName = "MyObjectName";
  InputStream inputStream = mock(InputStream.class);
  when(minioClient.getObject(bucketName, objectName)).thenReturn(inputStream);
  assertEquals(inputStream, minioClientFacade.getObject(objectName));
}
 
示例13
@Test
void testStore()
    throws IOException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException,
        InvalidArgumentException, InternalException, NoResponseException,
        InvalidBucketNameException, InsufficientDataException, ErrorResponseException {
  ReadableByteChannel fromChannel = mock(ReadableByteChannel.class);
  String blobId = "MyBlobId";
  when(idGenerator.generateId()).thenReturn(blobId);
  long size = 3L;
  ObjectStat objectStat = when(mock(ObjectStat.class).length()).thenReturn(size).getMock();
  when(minioClientFacade.statObject(blobId)).thenReturn(objectStat);
  assertEquals(create(blobId, size), minioBlobStore.store(fromChannel));
  verify(minioClientFacade)
      .putObject(eq(blobId), any(InputStream.class), eq("application/octet-stream"));
}
 
示例14
@Test
void testDelete()
    throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException,
        InvalidArgumentException, InternalException, NoResponseException,
        InvalidBucketNameException, XmlPullParserException, ErrorResponseException {
  String blobId = "MyBlobId";
  minioBlobStore.delete(blobId);
  verify(minioClientFacade).removeObject(blobId);
}
 
示例15
@Test
void testNewChannel()
    throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException,
        InvalidArgumentException, InternalException, NoResponseException,
        InvalidBucketNameException, XmlPullParserException, ErrorResponseException {
  String blobId = "MyBlobId";
  InputStream inputStream = mock(InputStream.class);
  when(minioClientFacade.getObject(blobId)).thenReturn(inputStream);
  assertDoesNotThrow(() -> minioBlobStore.newChannel(blobId));
}