代码拉取完成,页面将自动刷新
同步操作将从 CodeJason/飞书服务端SDK java 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package com.larksuite.oapi.sample.api;
import com.larksuite.oapi.core.AppSettings;
import com.larksuite.oapi.core.Config;
import com.larksuite.oapi.core.Domain;
import com.larksuite.oapi.core.Keys;
import com.larksuite.oapi.core.api.request.FormDataFile;
import com.larksuite.oapi.core.api.response.Response;
import com.larksuite.oapi.core.utils.Jsons;
import com.larksuite.oapi.sample.config.Configs;
import com.larksuite.oapi.service.image.v4.ImageService;
import com.larksuite.oapi.service.image.v4.model.Image;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
public class ImageSample {
// for Cutome APP(自建应用)
private static final AppSettings appSettings = Config.getInternalAppSettingsByEnv();
// config with redis store
// private static final Config config = Configs.getConfigWithRedisStore("https://open.feishu.cn", appSettings);
// private static final Config config = Configs.getConfig("https://open.feishu.cn", appSettings);
private static final Config config = Configs.getConfig(Domain.FeiShu, appSettings);
public static void main(String[] args) throws Exception {
//testPut();
testGet();
System.out.println("end");
}
private static void testPut() throws Exception {
config.getStore().put(Keys.tenantAccessTokenKey(config.getAppSettings().getAppID(), ""), "t-xxxxxxxxxxxxxxxxxxxxxxxxx", 1000, TimeUnit.DAYS);
ImageService service = new ImageService(config);
ImageService.ImagePutReqCall reqCall = service.getImages().put();
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("test.png")) {
reqCall.setImage(new FormDataFile().setContentStream(inputStream));
reqCall.setImageType("message");
Response<Image> response = reqCall.execute();
System.out.println();
System.out.println(Jsons.DEFAULT_GSON.toJson(response));
}
}
private static void testGet() throws Exception {
ImageService service = new ImageService(config);
try (FileOutputStream output = new FileOutputStream("test_download_img_1.png")) {
ImageService.ImageGetReqCall reqCall = service.getImages().get();
reqCall.setImageKey("img_e91d9511-dd89-49f2-aca7-380b26ea7beg");
reqCall.setResponseStream(output);
Response response = reqCall.execute();
System.out.println(response.getRequestID());
System.out.println(response.getHTTPStatusCode());
} catch (IOException e) {
e.printStackTrace();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。