org.jclouds.io.Payload.getContentMetadata()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中org.jclouds.io.Payload.getContentMetadata()方法的一些代码示例,展示了Payload.getContentMetadata()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Payload.getContentMetadata()方法的具体详情如下:
包路径:org.jclouds.io.Payload
类名称:Payload
方法名:getContentMetadata

Payload.getContentMetadata介绍

暂无

代码示例

代码示例来源:origin: rackerlabs/blueflood

try {
  long read = 0;
  long length = payload.getContentMetadata().getContentLength();
  OutputStream out = new FileOutputStream(tempFile, false);
  byte[] buf = new byte[BUF_SIZE];

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public PayloadBlobBuilder contentType(String contentType) {
  payload.getContentMetadata().setContentType(contentType);
  return this;
}

代码示例来源:origin: jclouds/legacy-jclouds

private void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) {
 buffer.append(
    Strings.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
       .getContentType())).append("\n");
}

代码示例来源:origin: org.jclouds.api/chef

@Override
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
 super.bindToRequest(request, String.format("{\"name\":\"%s\", \"private_key\": true}", payload));
 request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
 return request;
}

代码示例来源:origin: jclouds/legacy-jclouds

private void copyPayloadMetadata(Payload oldContent, Payload wiredPayload) {
 MutableContentMetadata oldMd = oldContent.getContentMetadata();
 MutableContentMetadata wiredMd = wiredPayload.getContentMetadata();
 if (oldMd.getContentLength() != null)
   wiredMd.setContentLength(oldMd.getContentLength());
 wiredMd.setContentType(oldMd.getContentType());
 wiredMd.setContentMD5(oldMd.getContentMD5());
 wiredMd.setContentDisposition(oldMd.getContentDisposition());
 wiredMd.setContentEncoding(oldMd.getContentEncoding());
 wiredMd.setContentLanguage(oldMd.getContentLanguage());
 wiredMd.setExpires(oldMd.getExpires());
}

代码示例来源:origin: io.cloudsoft.jclouds.api/atmos

@Override
  public URI apply(HttpResponse from) {
   if (from.getStatusCode() == 201 && request.getPayload().getContentMetadata().getContentLength() == 0) {
     releasePayload(from);
     return null;
   }
   return super.apply(from);
  }
}

代码示例来源:origin: org.jclouds.api/chef

@Override
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
 super.bindToRequest(request, String.format("{\"is_completed\":%s}", payload));
 request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
 return request;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Inject
protected GetJobRedirectionRetryHandler(BackoffLimitedRetryHandler backoffHandler) {
 super(backoffHandler);
 this.emptyPayload = Payloads.newPayload(new byte[]{});
 this.emptyPayload.getContentMetadata().setContentType(APPLICATION_JSON);     
}

代码示例来源:origin: jclouds/legacy-jclouds

private void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) {
 buffer.append(
    HttpUtils.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
       .getContentMD5())).append("\n");
 buffer.append(
    Strings.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
       .getContentType())).append("\n");
}

代码示例来源:origin: jclouds/legacy-jclouds

public static Long attemptToParseSizeAndRangeFromHeaders(HttpMessage from) throws HttpException {
 String contentRange = from.getFirstHeaderOrNull("Content-Range");
 if (contentRange == null && from.getPayload() != null) {
   return from.getPayload().getContentMetadata().getContentLength();
 } else if (contentRange != null) {
   return Long.parseLong(contentRange.substring(contentRange.lastIndexOf('/') + 1));
 }
 return null;
}

代码示例来源:origin: org.jclouds/jclouds-core

private void copyPayloadMetadata(Payload oldContent, Payload wiredPayload) {
 MutableContentMetadata oldMd = oldContent.getContentMetadata();
 MutableContentMetadata wiredMd = wiredPayload.getContentMetadata();
 if (oldMd.getContentLength() != null)
   wiredMd.setContentLength(oldMd.getContentLength());
 wiredMd.setContentType(oldMd.getContentType());
 wiredMd.setContentMD5(oldMd.getContentMD5());
 wiredMd.setContentDisposition(oldMd.getContentDisposition());
 wiredMd.setContentEncoding(oldMd.getContentEncoding());
 wiredMd.setContentLanguage(oldMd.getContentLanguage());
 wiredMd.setExpires(oldMd.getExpires());
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testSinglePart() throws IOException {
 assertEquals(EXPECTS.length(), 113);
 BindBlobToMultipartForm binder = new BindBlobToMultipartForm();
 HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost:8001").build();
 binder.bindToRequest(request, TEST_BLOB);
 assertEquals(Strings2.toString(request.getPayload()), EXPECTS);
 assertEquals(request.getPayload().getContentMetadata().getContentLength(), Long.valueOf(113));
 assertEquals(request.getPayload().getContentMetadata().getContentType(), "multipart/form-data; boundary="
    + BOUNDARY);
}

代码示例来源:origin: org.apache.jclouds.api/chef

@Override
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
 super.bindToRequest(request, String.format("{\"name\":\"%s\", \"private_key\": true}", payload));
 request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
 return request;
}

代码示例来源:origin: jclouds/legacy-jclouds

public static Payload payloadFromStringWithContentType(String payload, String contentType) {
 Payload p = Payloads.newStringPayload(payload);
 p.getContentMetadata().setContentType(contentType);
 return p;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
protected HttpUriRequest convert(HttpRequest request) throws IOException {
 HttpUriRequest returnVal = apacheHCUtils.convertToApacheRequest(request);
 if (request.getPayload() != null && request.getPayload().getContentMetadata().getContentMD5() != null){
   String md5 = base64().encode(asByteSource(request.getPayload().getInput()).hash(md5()).asBytes());
   returnVal.addHeader("Content-MD5", md5);
 }
 return returnVal;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
  public <R extends HttpRequest> R bindToRequest(R request, Object input) {
   checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!");
   checkNotNull(request, "request");

   AtmosObject object = AtmosObject.class.cast(input);
   checkNotNull(object.getPayload(), "object payload");
   checkArgument(object.getPayload().getContentMetadata().getContentLength() != null,
      "contentLength must be set, streaming not supported");
   return metaBinder.bindToRequest(request, object.getUserMetadata());
  }
}

代码示例来源:origin: io.cloudsoft.jclouds/jclouds-core

private void copyPayloadMetadata(Payload oldContent, Payload wiredPayload) {
 MutableContentMetadata oldMd = oldContent.getContentMetadata();
 MutableContentMetadata wiredMd = wiredPayload.getContentMetadata();
 if (oldMd.getContentLength() != null)
   wiredMd.setContentLength(oldMd.getContentLength());
 wiredMd.setContentType(oldMd.getContentType());
 wiredMd.setContentMD5(oldMd.getContentMD5());
 wiredMd.setContentDisposition(oldMd.getContentDisposition());
 wiredMd.setContentEncoding(oldMd.getContentEncoding());
 wiredMd.setContentLanguage(oldMd.getContentLanguage());
 wiredMd.setExpires(oldMd.getExpires());
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
  public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
   checkArgument(payload instanceof Drive, "this binder is only valid for Drive!");
   Drive create = Drive.class.cast(payload);
   Map<String, String> map = createDriveRequestToMap.apply(create);
   request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
   request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
   return request;
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

public static Payload stringPayload(String json) {
 Payload p = Payloads.newPayload(json);
 p.getContentMetadata().setContentType(APPLICATION_JSON);
 return p;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
 public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
   request.setPayload(Strings2.toInputStream(payload.toString()));
   request.getPayload().getContentMetadata().setContentLength((long) payload.toString().getBytes().length);
   return request;
 }
}

相关文章