mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
parent
a0d5744c49
commit
5dc66f839d
1 changed files with 12 additions and 6 deletions
|
@ -44,14 +44,20 @@ public class AttachmentHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SignalServiceAttachment> uploadAttachments(final List<String> attachments) throws AttachmentInvalidException, IOException {
|
public List<SignalServiceAttachment> uploadAttachments(final List<String> attachments) throws AttachmentInvalidException, IOException {
|
||||||
var attachmentStreams = createAttachmentStreams(attachments);
|
final var attachmentStreams = createAttachmentStreams(attachments);
|
||||||
|
|
||||||
|
try {
|
||||||
// Upload attachments here, so we only upload once even for multiple recipients
|
// Upload attachments here, so we only upload once even for multiple recipients
|
||||||
var attachmentPointers = new ArrayList<SignalServiceAttachment>(attachmentStreams.size());
|
final var attachmentPointers = new ArrayList<SignalServiceAttachment>(attachmentStreams.size());
|
||||||
for (var attachmentStream : attachmentStreams) {
|
for (final var attachmentStream : attachmentStreams) {
|
||||||
attachmentPointers.add(uploadAttachment(attachmentStream));
|
attachmentPointers.add(uploadAttachment(attachmentStream));
|
||||||
}
|
}
|
||||||
return attachmentPointers;
|
return attachmentPointers;
|
||||||
|
} finally {
|
||||||
|
for (final var attachmentStream : attachmentStreams) {
|
||||||
|
attachmentStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SignalServiceAttachmentStream> createAttachmentStreams(List<String> attachments) throws AttachmentInvalidException, IOException {
|
private List<SignalServiceAttachmentStream> createAttachmentStreams(List<String> attachments) throws AttachmentInvalidException, IOException {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue