Change attachment retrieval interface

This commit is contained in:
Moxie Marlinspike
2013-07-19 13:24:18 -07:00
parent 9287d413ac
commit fb378a6e00
4 changed files with 34 additions and 16 deletions

View File

@@ -134,10 +134,10 @@ public class PushServiceSocket {
return new Gson().fromJson(response.second, AttachmentKey.class).getId();
}
public List<File> retrieveAttachments(List<PushAttachmentPointer> attachmentIds)
public List<Pair<File,String>> retrieveAttachments(List<PushAttachmentPointer> attachmentIds)
throws IOException
{
List<File> attachments = new LinkedList<File>();
List<Pair<File,String>> attachments = new LinkedList<Pair<File,String>>();
for (PushAttachmentPointer attachmentId : attachmentIds) {
Pair<String, String> response = makeRequestForResponseHeader(String.format(ATTACHMENT_PATH, attachmentId.getKey()),
@@ -146,9 +146,10 @@ public class PushServiceSocket {
Log.w("PushServiceSocket", "Attachment: " + attachmentId.getKey() + " is at: " + response.first);
File attachment = File.createTempFile("attachment", ".tmp", context.getFilesDir());
downloadExternalFile(response.first, attachment);
attachment.deleteOnExit();
attachments.add(attachment);
downloadExternalFile(response.first, attachment);
attachments.add(new Pair<File, String>(attachment, attachmentId.getContentType()));
}
return attachments;