mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 12:30:39 +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");
|
final var id = ns.getString("id");
|
||||||
|
|
||||||
try (InputStream attachment = m.retrieveAttachment(id)) {
|
try (InputStream attachment = m.retrieveAttachment(id)) {
|
||||||
if (outputWriter instanceof PlainTextWriter writer) {
|
|
||||||
final var bytes = attachment.readAllBytes();
|
final var bytes = attachment.readAllBytes();
|
||||||
final var base64 = Base64.getEncoder().encodeToString(bytes);
|
final var base64 = Base64.getEncoder().encodeToString(bytes);
|
||||||
|
if (outputWriter instanceof PlainTextWriter writer) {
|
||||||
writer.println(base64);
|
writer.println(base64);
|
||||||
} else if (outputWriter instanceof JsonWriter writer) {
|
} else if (outputWriter instanceof JsonWriter writer) {
|
||||||
writer.write(new JsonAttachmentData(attachment));
|
writer.write(new JsonAttachmentData(base64));
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
throw new UserErrorException("Could not find attachment with ID: " + id, ex);
|
throw new UserErrorException("Could not find attachment with ID: " + id, ex);
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package org.asamk.signal.json;
|
package org.asamk.signal.json;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
public record JsonAttachmentData(
|
public record JsonAttachmentData(
|
||||||
@JsonSerialize(using = JsonStreamSerializer.class) InputStream data
|
String data
|
||||||
) {}
|
) {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue