Skip to content

Commit 3fdb749

Browse files
authored
ref: Remove default attachment content type (#2443)
Removed the default attachment content type. This is defined at server side.
1 parent 034ff5e commit 3fdb749

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This version adds a dependency on Swift.
3535
- Remove `- [SentryOptions sdkInfo]` (#2404)
3636
- Marks App hang's event stacktrace snapshot as true (#2441)
3737
- Enable user interaction tracing by default (#2442)
38+
- Remove default attachment content type (#2443)
3839

3940
## 7.31.2
4041

Sources/Sentry/Public/SentryAttachment.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SENTRY_NO_INIT
2727
*/
2828
- (instancetype)initWithData:(NSData *)data
2929
filename:(NSString *)filename
30-
contentType:(NSString *)contentType;
30+
contentType:(nullable NSString *)contentType;
3131

3232
/**
3333
* Initializes an attachment with a path. Uses the last path compontent of the path as a filename
@@ -63,27 +63,27 @@ SENTRY_NO_INIT
6363
*/
6464
- (instancetype)initWithPath:(NSString *)path
6565
filename:(NSString *)filename
66-
contentType:(NSString *)contentType;
66+
contentType:(nullable NSString *)contentType;
6767

6868
/**
6969
* The data of the attachment.
7070
*/
71-
@property (readonly, nonatomic, strong) NSData *_Nullable data;
71+
@property (readonly, nonatomic, strong, nullable) NSData *data;
7272

7373
/**
7474
* The path of the attachment.
7575
*/
76-
@property (readonly, nonatomic, copy) NSString *_Nullable path;
76+
@property (readonly, nonatomic, copy, nullable) NSString *path;
7777

7878
/**
7979
* The filename of the attachment to display in Sentry.
8080
*/
8181
@property (readonly, nonatomic, copy) NSString *filename;
8282

8383
/**
84-
* The content type of the attachment. Default is "application/octet-stream".
84+
* The content type of the attachment.
8585
*/
86-
@property (readonly, nonatomic, copy) NSString *contentType;
86+
@property (readonly, nonatomic, copy, nullable) NSString *contentType;
8787

8888
@end
8989

Sources/Sentry/SentryAttachment.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33

44
NS_ASSUME_NONNULL_BEGIN
55

6-
NSString *const DefaultContentType = @"application/octet-stream";
7-
86
@implementation SentryAttachment
97

108
- (instancetype)initWithData:(NSData *)data filename:(NSString *)filename
119
{
12-
return [self initWithData:data filename:filename contentType:DefaultContentType];
10+
return [self initWithData:data filename:filename contentType:nil];
1311
}
1412

1513
- (instancetype)initWithData:(NSData *)data
1614
filename:(NSString *)filename
17-
contentType:(NSString *)contentType
15+
contentType:(nullable NSString *)contentType
1816
{
1917

2018
if (self = [super init]) {
@@ -32,12 +30,12 @@ - (instancetype)initWithPath:(NSString *)path
3230

3331
- (instancetype)initWithPath:(NSString *)path filename:(NSString *)filename
3432
{
35-
return [self initWithPath:path filename:filename contentType:DefaultContentType];
33+
return [self initWithPath:path filename:filename contentType:nil];
3634
}
3735

3836
- (instancetype)initWithPath:(NSString *)path
3937
filename:(NSString *)filename
40-
contentType:(NSString *)contentType
38+
contentType:(nullable NSString *)contentType
4139
{
4240
if (self = [super init]) {
4341
_path = path;

Sources/Sentry/SentrySerialization.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data
284284
NSString *_Nullable contentType = [headerDictionary valueForKey:@"content_type"];
285285

286286
SentryEnvelopeItemHeader *itemHeader;
287-
if (nil != filename && nil != contentType) {
287+
if (nil != filename) {
288288
itemHeader = [[SentryEnvelopeItemHeader alloc] initWithType:type
289289
length:bodyLength
290290
filenname:filename

Tests/SentryTests/Protocol/SentryAttachmentTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SentryAttachmentTests: XCTestCase {
2727

2828
XCTAssertEqual(fixture.data, attachment.data)
2929
XCTAssertEqual(fixture.filename, attachment.filename)
30-
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
30+
XCTAssertNil(attachment.contentType)
3131
XCTAssertNil(attachment.path)
3232
}
3333

@@ -45,7 +45,7 @@ class SentryAttachmentTests: XCTestCase {
4545

4646
XCTAssertEqual(fixture.path, attachment.path)
4747
XCTAssertEqual(fixture.filename, attachment.filename)
48-
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
48+
XCTAssertNil(attachment.contentType)
4949
XCTAssertNil(attachment.data)
5050
}
5151

@@ -54,7 +54,7 @@ class SentryAttachmentTests: XCTestCase {
5454

5555
XCTAssertEqual("", attachment.path)
5656
XCTAssertEqual("", attachment.filename)
57-
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
57+
XCTAssertNil(attachment.contentType)
5858
XCTAssertNil(attachment.data)
5959
}
6060

@@ -87,7 +87,7 @@ class SentryAttachmentTests: XCTestCase {
8787

8888
XCTAssertEqual(fixture.path, attachment.path)
8989
XCTAssertEqual(filename, attachment.filename)
90-
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
90+
XCTAssertNil(attachment.contentType)
9191
XCTAssertNil(attachment.data)
9292
}
9393

0 commit comments

Comments
 (0)