图片上传的 Java API #751
-
之前的版本 Image image = group.uploadImage(new URL(“url地址”)); 现在的版本?Image image = group.uploadImage(new ExternalImage(new DeferredReusableInput())); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
自 @NotNull
private <T> T magic() {
throw new RuntimeException();
}
ExternalResource resource = magic();
public void externalResource() throws IOException {
resource.inputStream();
contact.uploadImage(resource); // base method
ExternalResource r;
r = ExternalResource.create((InputStream) magic()); // throws IOException
r = ExternalResource.create((File) magic());
r = ExternalResource.create((RandomAccessFile) magic());
ExternalResource.uploadAsImage(r, contact); // returns Image
ExternalResource.sendAsImage(r, contact); // returns MessageReceipt
ExternalResource.uploadAsImage((ExternalResource) magic(), contact); // returns Image
ExternalResource.uploadAsImage((File) magic(), contact); // returns Image
ExternalResource.uploadAsImage((InputStream) magic(), contact); // returns Image
ExternalResource.sendAsImage((ExternalResource) magic(), contact); // returns MessageReceipt
ExternalResource.sendAsImage((File) magic(), contact); // returns MessageReceipt
ExternalResource.sendAsImage((InputStream) magic(), contact); // returns MessageReceipt
Contact.uploadImage(contact, (ExternalResource) magic()); // returns Image
Contact.uploadImage(contact, (File) magic()); // returns Image
Contact.uploadImage(contact, (InputStream) magic()); // returns Image
Contact.sendImage(contact, (ExternalResource) magic()); // returns MessageReceipt
Contact.sendImage(contact, (File) magic()); // returns MessageReceipt
Contact.sendImage(contact, (InputStream) magic()); // returns MessageReceipt
// experimental
ExternalResource.uploadAsGroupVoice(magic(), (Group) contact);
} 示例详见 https://github.com/mamoe/mirai/blob/dev/mirai-core/src/jvmTest/kotlin/JavaApiTests.java |
Beta Was this translation helpful? Give feedback.
自
2.0-M2-dev-11
: