mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 04:20:38 +00:00
Add missing files to attachment fix
This commit is contained in:
parent
54a55f4ea9
commit
01b4933dcc
2 changed files with 4 additions and 8 deletions
|
@ -40,12 +40,12 @@ public class GetAttachmentCommand implements JsonRpcLocalCommand {
|
|||
final var id = ns.getString("id");
|
||||
|
||||
try (InputStream attachment = m.retrieveAttachment(id)) {
|
||||
final var bytes = attachment.readAllBytes();
|
||||
final var base64 = Base64.getEncoder().encodeToString(bytes);
|
||||
if (outputWriter instanceof PlainTextWriter writer) {
|
||||
final var bytes = attachment.readAllBytes();
|
||||
final var base64 = Base64.getEncoder().encodeToString(bytes);
|
||||
writer.println(base64);
|
||||
} else if (outputWriter instanceof JsonWriter writer) {
|
||||
writer.write(new JsonAttachmentData(attachment));
|
||||
writer.write(new JsonAttachmentData(base64));
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
throw new UserErrorException("Could not find attachment with ID: " + id, ex);
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public record JsonAttachmentData(
|
||||
@JsonSerialize(using = JsonStreamSerializer.class) InputStream data
|
||||
String data
|
||||
) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue