Add filename to attachment streams.

pull/1/head
Matthew Chen 9 years ago
parent 5d4b96924d
commit b986db808d

@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSAttachmentStream : TSAttachment @interface TSAttachmentStream : TSAttachment
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithContentType:(NSString *)contentType NS_DESIGNATED_INITIALIZER; - (instancetype)initWithContentType:(NSString *)contentType filename:(NSString *)filename NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithPointer:(TSAttachmentPointer *)pointer NS_DESIGNATED_INITIALIZER; - (instancetype)initWithPointer:(TSAttachmentPointer *)pointer NS_DESIGNATED_INITIALIZER;
// Though now required, `digest` may be null for pre-existing records or from // Though now required, `digest` may be null for pre-existing records or from

@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation TSAttachmentStream @implementation TSAttachmentStream
- (instancetype)initWithContentType:(NSString *)contentType - (instancetype)initWithContentType:(NSString *)contentType filename:(NSString *)filename
{ {
self = [super initWithContentType:contentType]; self = [super initWithContentType:contentType];
if (!self) { if (!self) {
@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
// state, but this constructor is used only for new outgoing // state, but this constructor is used only for new outgoing
// attachments which haven't been uploaded yet. // attachments which haven't been uploaded yet.
_isUploaded = NO; _isUploaded = NO;
_filename = filename;
return self; return self;
} }

@ -516,7 +516,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
NSData *dataCopy = (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(10, 0) ? data : [data copy]); NSData *dataCopy = (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(10, 0) ? data : [data copy]);
dispatch_async([OWSDispatch attachmentsQueue], ^{ dispatch_async([OWSDispatch attachmentsQueue], ^{
TSAttachmentStream *attachmentStream = [[TSAttachmentStream alloc] initWithContentType:contentType]; TSAttachmentStream *attachmentStream =
[[TSAttachmentStream alloc] initWithContentType:contentType filename:filename];
NSError *error; NSError *error;
[attachmentStream writeData:dataCopy error:&error]; [attachmentStream writeData:dataCopy error:&error];

Loading…
Cancel
Save