Skip to content

Commit

Permalink
ref: Remove default attachment content type (#2443)
Browse files Browse the repository at this point in the history
Removed the default attachment content type.
This is defined at server side.
  • Loading branch information
brustolin authored Nov 25, 2022
1 parent 034ff5e commit 3fdb749
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This version adds a dependency on Swift.
- Remove `- [SentryOptions sdkInfo]` (#2404)
- Marks App hang's event stacktrace snapshot as true (#2441)
- Enable user interaction tracing by default (#2442)
- Remove default attachment content type (#2443)

## 7.31.2

Expand Down
12 changes: 6 additions & 6 deletions Sources/Sentry/Public/SentryAttachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SENTRY_NO_INIT
*/
- (instancetype)initWithData:(NSData *)data
filename:(NSString *)filename
contentType:(NSString *)contentType;
contentType:(nullable NSString *)contentType;

/**
* Initializes an attachment with a path. Uses the last path compontent of the path as a filename
Expand Down Expand Up @@ -63,27 +63,27 @@ SENTRY_NO_INIT
*/
- (instancetype)initWithPath:(NSString *)path
filename:(NSString *)filename
contentType:(NSString *)contentType;
contentType:(nullable NSString *)contentType;

/**
* The data of the attachment.
*/
@property (readonly, nonatomic, strong) NSData *_Nullable data;
@property (readonly, nonatomic, strong, nullable) NSData *data;

/**
* The path of the attachment.
*/
@property (readonly, nonatomic, copy) NSString *_Nullable path;
@property (readonly, nonatomic, copy, nullable) NSString *path;

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

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

@end

Expand Down
10 changes: 4 additions & 6 deletions Sources/Sentry/SentryAttachment.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@

NS_ASSUME_NONNULL_BEGIN

NSString *const DefaultContentType = @"application/octet-stream";

@implementation SentryAttachment

- (instancetype)initWithData:(NSData *)data filename:(NSString *)filename
{
return [self initWithData:data filename:filename contentType:DefaultContentType];
return [self initWithData:data filename:filename contentType:nil];
}

- (instancetype)initWithData:(NSData *)data
filename:(NSString *)filename
contentType:(NSString *)contentType
contentType:(nullable NSString *)contentType
{

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

- (instancetype)initWithPath:(NSString *)path filename:(NSString *)filename
{
return [self initWithPath:path filename:filename contentType:DefaultContentType];
return [self initWithPath:path filename:filename contentType:nil];
}

- (instancetype)initWithPath:(NSString *)path
filename:(NSString *)filename
contentType:(NSString *)contentType
contentType:(nullable NSString *)contentType
{
if (self = [super init]) {
_path = path;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentrySerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data
NSString *_Nullable contentType = [headerDictionary valueForKey:@"content_type"];

SentryEnvelopeItemHeader *itemHeader;
if (nil != filename && nil != contentType) {
if (nil != filename) {
itemHeader = [[SentryEnvelopeItemHeader alloc] initWithType:type
length:bodyLength
filenname:filename
Expand Down
8 changes: 4 additions & 4 deletions Tests/SentryTests/Protocol/SentryAttachmentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SentryAttachmentTests: XCTestCase {

XCTAssertEqual(fixture.data, attachment.data)
XCTAssertEqual(fixture.filename, attachment.filename)
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
XCTAssertNil(attachment.contentType)
XCTAssertNil(attachment.path)
}

Expand All @@ -45,7 +45,7 @@ class SentryAttachmentTests: XCTestCase {

XCTAssertEqual(fixture.path, attachment.path)
XCTAssertEqual(fixture.filename, attachment.filename)
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
XCTAssertNil(attachment.contentType)
XCTAssertNil(attachment.data)
}

Expand All @@ -54,7 +54,7 @@ class SentryAttachmentTests: XCTestCase {

XCTAssertEqual("", attachment.path)
XCTAssertEqual("", attachment.filename)
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
XCTAssertNil(attachment.contentType)
XCTAssertNil(attachment.data)
}

Expand Down Expand Up @@ -87,7 +87,7 @@ class SentryAttachmentTests: XCTestCase {

XCTAssertEqual(fixture.path, attachment.path)
XCTAssertEqual(filename, attachment.filename)
XCTAssertEqual(fixture.defaultContentType, attachment.contentType)
XCTAssertNil(attachment.contentType)
XCTAssertNil(attachment.data)
}

Expand Down

0 comments on commit 3fdb749

Please sign in to comment.