mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 19:10:38 +00:00
Add command to get an attachment (#1080)
* Add command to get an attachment * Refactor retrieving of attachments to use StreamDetails * Refactor AttachmentCommand to GetAttachmentCommand * Minor improvements to GetAttachmentCommand * Use JSON serializer to serialize binary data Serializing the stream is better for memory handling than loading the whole thing into the file. * Clean up unneeded class * Added command to doc Co-authored-by: cedb <cedb@keylimebox.org>
This commit is contained in:
parent
bf76c04664
commit
2e4d346bc8
10 changed files with 138 additions and 0 deletions
|
@ -0,0 +1,9 @@
|
|||
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
|
||||
) {}
|
|
@ -0,0 +1,20 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class JsonStreamSerializer extends JsonSerializer<InputStream> {
|
||||
|
||||
@Override
|
||||
public void serialize(
|
||||
final InputStream value,
|
||||
final JsonGenerator jsonGenerator,
|
||||
final SerializerProvider serializers
|
||||
) throws IOException {
|
||||
jsonGenerator.writeBinary(value, -1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue