Add support for attachment file names

Send, receive, and save attachment filenames. Use them as suggested
names when saving files.

// FREEBIE
This commit is contained in:
lilia 2017-04-18 11:26:05 -07:00
parent a256f17e19
commit fc514aa96f
5 changed files with 18 additions and 2 deletions

View File

@ -39049,6 +39049,9 @@ MessageSender.prototype = {
proto.id = id;
proto.contentType = attachment.contentType;
proto.digest = result.digest;
if (attachment.fileName) {
proto.fileName = attachment.fileName;
}
return proto;
});
}.bind(this));

View File

@ -91,6 +91,10 @@
}
},
suggestedName: function() {
if (this.model.fileName) {
return this.model.fileName;
}
var suggestion = 'signal';
if (this.timestamp) {
suggestion += moment(this.timestamp).format('-YYYY-MM-DD-HHmmss');

View File

@ -223,12 +223,17 @@
},
readFile: function(file) {
var contentType = file.type;
return new Promise(function(resolve, reject) {
var FR = new FileReader();
FR.onload = function(e) {
resolve({data: e.target.result, contentType: contentType});
resolve({
data: e.target.result,
contentType: file.type,
fileName: file.name
});
};
FR.onerror = reject;
FR.onabort = reject;
FR.readAsArrayBuffer(file);
});
},

View File

@ -124,6 +124,9 @@ MessageSender.prototype = {
proto.id = id;
proto.contentType = attachment.contentType;
proto.digest = result.digest;
if (attachment.fileName) {
proto.fileName = attachment.fileName;
}
return proto;
});
}.bind(this));

View File

@ -123,6 +123,7 @@ message AttachmentPointer {
optional uint32 size = 4;
optional bytes thumbnail = 5;
optional bytes digest = 6;
optional string fileName = 7;
}
message GroupContext {