com.cloudinary.Url.format()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(96)

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

Url.format介绍

暂无

代码示例

代码示例来源:origin: com.cloudinary/cloudinary-core

private void appendVideoSources(StringBuilder html, String source, String sourceType) {
  Url sourceUrl = this.clone();
  if (this.sourceTransformation != null) {
    Transformation transformation = this.transformation;
    Transformation sourceTransformation = null;
    if (this.sourceTransformation.get(sourceType) != null)
      sourceTransformation = new Transformation(this.sourceTransformation.get(sourceType));
    if (transformation == null) {
      transformation = sourceTransformation;
    } else if (sourceTransformation != null) {
      transformation = transformation.chainWith(sourceTransformation);
    }
    sourceUrl.transformation(transformation);
  }
  String src = sourceUrl.format(sourceType).generate(source);
  String videoType = sourceType;
  if (sourceType.equals("ogv"))
    videoType = "ogg";
  String mimeType = "video/" + videoType;
  html.append("<source src='").append(src).append("' type='").append(mimeType).append("'>");
}

代码示例来源:origin: cloudinary/cloudinary_java

private void appendVideoSources(StringBuilder html, String source, String sourceType) {
  Url sourceUrl = this.clone();
  if (this.sourceTransformation != null) {
    Transformation transformation = this.transformation;
    Transformation sourceTransformation = null;
    if (this.sourceTransformation.get(sourceType) != null)
      sourceTransformation = new Transformation(this.sourceTransformation.get(sourceType));
    if (transformation == null) {
      transformation = sourceTransformation;
    } else if (sourceTransformation != null) {
      transformation = transformation.chainWith(sourceTransformation);
    }
    sourceUrl.transformation(transformation);
  }
  String src = sourceUrl.format(sourceType).generate(source);
  String videoType = sourceType;
  if (sourceType.equals("ogv"))
    videoType = "ogg";
  String mimeType = "video/" + videoType;
  html.append("<source src='").append(src).append("' type='").append(mimeType).append("'>");
}

代码示例来源:origin: com.cloudinary/cloudinary-core

format(format);

代码示例来源:origin: cloudinary/cloudinary_java

format(format);

代码示例来源:origin: com.cloudinary/cloudinary-core

private String finalizePosterUrl(String source) {
  String posterUrl = null;
  if (this.posterUrl != null) {
    posterUrl = this.posterUrl.generate();
  } else if (this.posterTransformation != null) {
    posterUrl = this.clone().format("jpg").transformation(new Transformation(this.posterTransformation))
        .generate(source);
  } else if (this.posterSource != null) {
    if (!StringUtils.isEmpty(this.posterSource))
      posterUrl = this.clone().format("jpg").generate(this.posterSource);
  } else {
    posterUrl = this.clone().format("jpg").generate(source);
  }
  return posterUrl;
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testExplicit() throws IOException {
  Map result = cloudinary.uploader().explicit("sample", asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)), "type", "upload", "moderation", "manual"));
  String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("jpg").version(result.get("version")).generate("sample");
  String eagerUrl = (String) ((Map) ((List) result.get("eager")).get(0)).get("url");
  String cloudName = cloudinary.config.cloudName;
  assertEquals(eagerUrl.substring(eagerUrl.indexOf(cloudName)), url.substring(url.indexOf(cloudName)));
}

代码示例来源:origin: cloudinary/cloudinary_java

private String finalizePosterUrl(String source) {
  String posterUrl = null;
  if (this.posterUrl != null) {
    posterUrl = this.posterUrl.generate();
  } else if (this.posterTransformation != null) {
    posterUrl = this.clone().format("jpg").transformation(new Transformation(this.posterTransformation))
        .generate(source);
  } else if (this.posterSource != null) {
    if (!StringUtils.isEmpty(this.posterSource))
      posterUrl = this.clone().format("jpg").generate(this.posterSource);
  } else {
    posterUrl = this.clone().format("jpg").generate(source);
  }
  return posterUrl;
}

代码示例来源:origin: cloudinary/cloudinary_android

@Override
public void onBindViewHolder(final EffectsGalleryAdapter.ImageViewHolder holder, int position) {
  EffectData data = images.get(position);
  holder.itemView.setTag(images.get(position));
  holder.nameTextView.setText(data.getName());
  // force image format (webp in this case) so that both video and images are downloaded as images.
  Url baseUrl = MediaManager.get().url().format("webp").resourceType(resourceType).publicId(data.getPublicId()).transformation(data.getTransformation());
  MediaManager.get().responsiveUrl(AUTO_FILL)
      .stepSize(50)
      .generate(baseUrl, holder.imageView, new ResponsiveUrl.Callback() {
        @Override
        public void onUrlReady(Url url) {
          Picasso.get().load(url.generate()).placeholder(R.drawable.placeholder).into(holder.imageView);
        }
      });
  if (selected != null && selected.equals(data)) {
    holder.selection.setVisibility(View.VISIBLE);
  } else {
    holder.selection.setVisibility(View.INVISIBLE);
  }
}

代码示例来源:origin: cloudinary/cloudinary_android

} else {
  String publicId = resource.getCloudinaryPublicId();
  Url url = MediaManager.get().url().publicId(publicId).resourceType(resource.getResourceType()).format("webp");
  MediaManager.get().responsiveUrl(ResponsiveUrl.Preset.AUTO_FILL)
      .generate(url, holder.imageView, new ResponsiveUrl.Callback() {

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testNotSignTheUrlSuffix() {
  Pattern pattern = Pattern.compile("s--[0-9A-Za-z_-]{8}--");
  String url = cloudinary.url().format("jpg").signed(true).generate("test");
  Matcher matcher = pattern.matcher(url);
  matcher.find();
  String expectedSignature = url.substring(matcher.start(), matcher.end());
  String actual = cloudinary.url().format("jpg").privateCdn(true).signed(true).suffix("hello").generate("test");
  assertEquals("http://test123-res.cloudinary.com/images/" + expectedSignature + "/test/hello.jpg", actual);
  url = cloudinary.url().format("jpg").signed(true).transformation(new Transformation().angle(0)).generate("test");
  matcher = pattern.matcher(url);
  matcher.find();
  expectedSignature = url.substring(matcher.start(), matcher.end());
  actual = cloudinary.url().format("jpg").privateCdn(true).signed(true).suffix("hello").transformation(new Transformation().angle(0)).generate("test");
  assertEquals("http://test123-res.cloudinary.com/images/" + expectedSignature + "/a_0/test/hello.jpg", actual);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testFormat() {
  // should use format from options
  String result = cloudinary.url().format("jpg").generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "test.jpg", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

if (namedTransformation != null) baseTransformation.named(namedTransformation);
url.transformation(baseTransformation.chain().rawTransformation(transformation));
if (format != null) url.format(format);
if (type != null) url.type(type);
if (resourceType != null) url.resourceType(resourceType);

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testFetchFormat() {
  // should support format for fetch urls
  String result = cloudinary.url().format("jpg").type("fetch").generate("http://cloudinary.com/images/old_logo.png");
  assertEquals("http://res.cloudinary.com/test123/image/fetch/f_jpg/http://cloudinary.com/images/old_logo.png", result);
}

代码示例来源:origin: cloudinary/cloudinary_android

public static String getCroppedThumbnailUrl(int size, Resource resource) {
  return MediaManager.get().getCloudinary().url()
      .resourceType(resource.getResourceType())
      .transformation(new Transformation().gravity("auto").width(size).height(size))
      .format("webp")
      .generate(resource.getCloudinaryPublicId());
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testPutFormatAfterUrlSuffix() {
  String actual = cloudinary.url().suffix("hello").privateCdn(true).format("jpg").generate("test");
  assertEquals("http://test123-res.cloudinary.com/images/test/hello.jpg", actual);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
  public void testUrlCloneConfig(){
    // verify that secure (from url.config) is cloned as well:
    Url url = cloudinary.url().cloudName("cloud").format("frmt").publicId("123").secure(true);
    assertEquals("https://res.cloudinary.com/cloud/image/upload/123.frmt", url.clone().generate());
  }
}

代码示例来源:origin: cloudinary/cloudinary_android

@Test
public void testExplicit() throws Exception {
  if (cloudinary.config.apiSecret == null)
    return;
  JSONObject result = new JSONObject(cloudinary.uploader().explicit("sample",
      ObjectUtils.asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)), "type", "upload")));
  String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("jpg")
      .version(result.get("version")).generate("sample");
  assertEquals(url, result.getJSONArray("eager").getJSONObject(0).get("url"));
}

代码示例来源:origin: cloudinary/cloudinary_java

.poster(cloudinary.url()
    .publicId("my_poster")
    .format("jpg")
    .transformation(new Transformation().gravity("north")))
.videoTag("movie", emptyMap());

相关文章