Package com.elasticinbox.core.blob

Examples of com.elasticinbox.core.blob.BlobDataSource


    // Write blob
    long origSize = testWrite(bs);

    // Read blob back
    BlobDataSource ds = bs.read(blobUri);
    long newSize = IOUtils.getInputStreamSize(ds.getUncompressedInputStream());

    // Check written Blob URI
    assertThat(blobUri.toString(), equalTo(expextedBlobUrl));

    // Check written Blob size
View Full Code Here


    // Check Blob URI
    assertThat(blobUri.toString(), equalTo(expextedBlobUrl));

    // Read blob back
    BlobDataSource ds = bs.read(blobUri);

    // Read blob back again
    ds = bs.read(blobUri);
    long newSize = IOUtils.getInputStreamSize(ds.getUncompressedInputStream());

    // Check Blob size
    assertThat(newSize, equalTo(origSize));

    // Delete
View Full Code Here

    // Check written Blob URI
    assertThat(blobUri.toString(), equalTo(expextedBlobUrl));

    // Read blob back
    BlobDataSource ds = bs.read(blobUri);
    long newSize = IOUtils.getInputStreamSize(ds.getUncompressedInputStream());

    // Check written Blob size
    assertThat(newSize, equalTo(origSize));

    // Delete
View Full Code Here

    UUID messageId = UUID.fromString(blobUri.getName());
    byte[] messageBlock = BlobPersistence.readBlock(messageId, DATABASE_DEFAULT_BLOCK_ID);
    InputStream in = ByteStreams.newInputStreamSupplier(messageBlock).getInput();

    return new BlobDataSource(uri, in);
  }
View Full Code Here

      }
    } else {
      in = CloudStoreProxy.read(uri);
    }

    return new BlobDataSource(uri, in);
  }
View Full Code Here

  public BlobDataSource read(final URI uri) throws IOException
  {
    // check if blob was stored for the message
    Assert.notNull(uri, "URI cannot be null");

    BlobDataSource blobDS;
    BlobURI blobUri = new BlobURI().fromURI(uri);

    if (blobUri.getProfile().equals(DatabaseConstants.DATABASE_PROFILE)) {
      blobDS = dbBlobStorage.read(uri);
    } else {
      blobDS = cloudBlobStorage.read(uri);
    }

    // if compressed, add compression handler to data source
    if ((blobUri.getCompression() != null && blobUri.getCompression()
        .equals(DeflateCompressionHandler.COMPRESSION_TYPE_DEFLATE)) ||
        // TODO: deprecated suffix based compression detection
        // kept for backward compatibility with 0.3
        blobUri.getName().endsWith(BlobStoreConstants.COMPRESS_SUFFIX))
    {
      CompressionHandler ch = new DeflateCompressionHandler();
      return new BlobDataSource(uri, blobDS.getInputStream(), ch);
    } else {
      return blobDS;
    }
  }
View Full Code Here

    Mailbox mailbox = new Mailbox(user, domain);

    Response response;

    try {
      BlobDataSource blobDS = messageDAO.getRaw(mailbox, messageId);

      if (acceptEncoding != null && acceptEncoding.contains("deflate")
          && blobDS.isCompressed())
      {
        response = Response
            .ok(blobDS.getInputStream(), MediaType.TEXT_PLAIN)
            .header(HttpHeaders.CONTENT_ENCODING, "deflate").build();
      } else {
        response = Response.ok(blobDS.getUncompressedInputStream(),
            MediaType.TEXT_PLAIN).build();
      }
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.elasticinbox.core.blob.BlobDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.