private Payload createPayload(byte[] content) {
      Payload payload = null;

      if (content.length > 0) {
        payload = new ByteArrayPayload(content);
        ContentMetadata cm =
            metaData.toBuilder().contentLength((long) content.length).contentMD5(null).build();
        payload.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(cm));
      }

      return payload;
    }
 public static MutableBlobMetadata copy(MutableBlobMetadata in) {
   ByteArrayOutputStream bout = new ByteArrayOutputStream();
   ObjectOutput os;
   try {
     os = new ObjectOutputStream(bout);
     os.writeObject(in);
     ObjectInput is = new ObjectInputStream(new ByteArrayInputStream(bout.toByteArray()));
     MutableBlobMetadata metadata = (MutableBlobMetadata) is.readObject();
     convertUserMetadataKeysToLowercase(metadata);
     metadata.setContentMetadata(
         BaseMutableContentMetadata.fromContentMetadata(
             in.getContentMetadata().toBuilder().build()));
     return metadata;
   } catch (Exception e) {
     propagate(e);
     assert false : "exception should have propagated: " + e;
     return null;
   }
 }
  @Override
  public Iterable<Payload> slice(Payload input, long size) {
    checkNotNull(input, "input");
    checkArgument(size >= 0, "size must be non-negative but was: %s", size);

    ContentMetadata meta =
        BaseMutableContentMetadata.fromContentMetadata(input.getContentMetadata())
            .toBuilder()
            .contentLength(size)
            .contentMD5(null)
            .build();
    Object rawContent = input.getRawContent();
    if (rawContent instanceof File) {
      return doSlice((File) rawContent, meta);
    } else if (rawContent instanceof String) {
      return doSlice((String) rawContent, meta);
    } else if (rawContent instanceof byte[]) {
      return doSlice((byte[]) rawContent, meta);
    } else if (rawContent instanceof InputStream) {
      return doSlice((InputStream) rawContent, meta);
    } else {
      return doSlice(input, meta);
    }
  }
 protected Payload copyMetadataAndSetLength(Payload input, Payload returnVal, long length) {
   returnVal.setContentMetadata(
       BaseMutableContentMetadata.fromContentMetadata(
           input.getContentMetadata().toBuilder().contentLength(length).contentMD5(null).build()));
   return returnVal;
 }