Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Jul 18, 2017
1 parent 082128f commit 49f180f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion backends/rapidpro/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ func (ts *MsgTestSuite) TestWriteAttachment() {
err := ts.b.WriteMsg(msg)
ts.NoError(err)
ts.True(strings.HasPrefix(msg.Attachments()[0], "text/plain"))
ts.True(strings.HasSuffix(msg.Attachments()[0], ".txt"), "Attachment: %s", msg.Attachments()[0])

// use an extension for our attachment instead
msg = ts.b.NewIncomingMsg(knChannel, urn, "jpg attachment").(*DBMsg)
Expand Down
12 changes: 7 additions & 5 deletions backends/rapidpro/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ func downloadMediaToS3(b *backend, msgUUID courier.MsgUUID, mediaURL string) (st
// we still don't know our mime type, use our content header instead
if mimeType == "" {
mimeType, _, _ = mime.ParseMediaType(resp.Header.Get("Content-Type"))
extensions, err := mime.ExtensionsByType(mimeType)
if extensions == nil || err != nil {
extension = ""
} else {
extension = extensions[0][1:]
if extension == "" {
extensions, err := mime.ExtensionsByType(mimeType)
if extensions == nil || err != nil {
extension = ""
} else {
extension = extensions[0][1:]
}
}
}

Expand Down

0 comments on commit 49f180f

Please sign in to comment.