io.minio.errors.InsufficientDataException Java Examples

The following examples show how to use io.minio.errors.InsufficientDataException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MinioClientComponentImpl.java    From sctalk with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #2
Source File: CacheService.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example #3
Source File: MinioClientComponentImpl.java    From sctalk with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #4
Source File: MinioClientComponentImpl.java    From sctalk with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #5
Source File: MinioClientFacade.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** @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);
}
 
Example #6
Source File: MinioClientFacade.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** @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;
}
 
Example #7
Source File: MinioClientFacade.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** @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);
}
 
Example #8
Source File: MinioClientFacade.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** @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);
}
 
Example #9
Source File: MinioClientFacadeTest.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #10
Source File: MinioClientFacadeTest.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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));
}
 
Example #11
Source File: MinioClientFacadeTest.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #12
Source File: MinioClientFacadeTest.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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));
}
 
Example #13
Source File: MinioBlobStoreTest.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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"));
}
 
Example #14
Source File: MinioBlobStoreTest.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
void testDelete()
    throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException,
        InvalidArgumentException, InternalException, NoResponseException,
        InvalidBucketNameException, XmlPullParserException, ErrorResponseException {
  String blobId = "MyBlobId";
  minioBlobStore.delete(blobId);
  verify(minioClientFacade).removeObject(blobId);
}
 
Example #15
Source File: MinioBlobStoreTest.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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));
}