Class Attachment
- java.lang.Object
-
- io.sentry.Attachment
-
public final class Attachment extends java.lang.Object
You can use an attachment to store additional files alongside an event or transaction.
-
-
Constructor Summary
Constructors Constructor Description Attachment(@org.jetbrains.annotations.NotNull byte[] bytes, @NotNull java.lang.String filename)
Initializes an Attachment with bytes and a filename.Attachment(@org.jetbrains.annotations.NotNull byte[] bytes, @NotNull java.lang.String filename, @NotNull java.lang.String contentType)
Initializes an Attachment with bytes, a filename, and a content type.Attachment(@org.jetbrains.annotations.NotNull byte[] bytes, @NotNull java.lang.String filename, @NotNull java.lang.String contentType, boolean addToTransactions)
Initializes an Attachment with bytes, a filename, a content type, and addToTransactions.Attachment(@NotNull java.lang.String pathname)
Initializes an Attachment with a path.Attachment(@NotNull java.lang.String pathname, @NotNull java.lang.String filename)
Initializes an Attachment with a path and a filename.Attachment(@NotNull java.lang.String pathname, @NotNull java.lang.String filename, @NotNull java.lang.String contentType)
Initializes an Attachment with a path, a filename, and a content type.Attachment(@NotNull java.lang.String pathname, @NotNull java.lang.String filename, @NotNull java.lang.String contentType, boolean addToTransactions)
Initializes an Attachment with a path, a filename, a content type, and addToTransactions.Attachment(@NotNull java.lang.String pathname, @NotNull java.lang.String filename, @NotNull java.lang.String contentType, boolean addToTransactions, @Nullable java.lang.String attachmentType)
Initializes an Attachment with a path, a filename, a content type, addToTransactions, and attachmentType.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable java.lang.String
getAttachmentType()
Returns the attachmentType type@org.jetbrains.annotations.Nullable byte[]
getBytes()
Gets the bytes of the attachment.@NotNull java.lang.String
getContentType()
Gets the content type of the attachment.@NotNull java.lang.String
getFilename()
Gets the name of the attachment to display in Sentry.@Nullable java.lang.String
getPathname()
Gets the pathname string of the attachment.
-
-
-
Constructor Detail
-
Attachment
public Attachment(@NotNull @org.jetbrains.annotations.NotNull byte[] bytes, @NotNull @NotNull java.lang.String filename)
Initializes an Attachment with bytes and a filename. Sets addToTransaction tofalse
.- Parameters:
bytes
- The bytes of file.filename
- The name of the attachment to display in Sentry.
-
Attachment
public Attachment(@NotNull @org.jetbrains.annotations.NotNull byte[] bytes, @NotNull @NotNull java.lang.String filename, @NotNull @NotNull java.lang.String contentType)
Initializes an Attachment with bytes, a filename, and a content type. Sets addToTransaction tofalse
.- Parameters:
bytes
- The bytes of file.filename
- The name of the attachment to display in Sentry.contentType
- The content type of the attachment.
-
Attachment
public Attachment(@NotNull @org.jetbrains.annotations.NotNull byte[] bytes, @NotNull @NotNull java.lang.String filename, @NotNull @NotNull java.lang.String contentType, boolean addToTransactions)
Initializes an Attachment with bytes, a filename, a content type, and addToTransactions.- Parameters:
bytes
- The bytes of file.filename
- The name of the attachment to display in Sentry.contentType
- The content type of the attachment.addToTransactions
-true
if the SDK should add this attachment to everyITransaction
or set tofalse
if it shouldn't.
-
Attachment
public Attachment(@NotNull @NotNull java.lang.String pathname)
Initializes an Attachment with a path. The filename of the file located at the path is used. Sets addToTransaction tofalse
.The file located at the pathname is read lazily when the SDK captures an event or transaction not when the attachment is initialized. The pathname string is converted into an abstract pathname before reading the file.
- Parameters:
pathname
- The pathname string of the file to upload as an attachment.
-
Attachment
public Attachment(@NotNull @NotNull java.lang.String pathname, @NotNull @NotNull java.lang.String filename)
Initializes an Attachment with a path and a filename. Sets addToTransaction tofalse
.The file located at the pathname is read lazily when the SDK captures an event or transaction not when the attachment is initialized. The pathname string is converted into an abstract pathname before reading the file.
- Parameters:
pathname
- The pathname string of the file to upload as an attachment.filename
- The name of the attachment to display in Sentry.
-
Attachment
public Attachment(@NotNull @NotNull java.lang.String pathname, @NotNull @NotNull java.lang.String filename, @NotNull @NotNull java.lang.String contentType)
Initializes an Attachment with a path, a filename, and a content type. Sets addToTransaction tofalse
.The file located at the pathname is read lazily when the SDK captures an event or transaction not when the attachment is initialized. The pathname string is converted into an abstract pathname before reading the file.
- Parameters:
pathname
- The pathname string of the file to upload as an attachment.filename
- The name of the attachment to display in Sentry.contentType
- The content type of the attachment.
-
Attachment
public Attachment(@NotNull @NotNull java.lang.String pathname, @NotNull @NotNull java.lang.String filename, @NotNull @NotNull java.lang.String contentType, boolean addToTransactions)
Initializes an Attachment with a path, a filename, a content type, and addToTransactions.The file located at the pathname is read lazily when the SDK captures an event or transaction not when the attachment is initialized. The pathname string is converted into an abstract pathname before reading the file.
- Parameters:
pathname
- The pathname string of the file to upload as an attachment.filename
- The name of the attachment to display in Sentry.contentType
- The content type of the attachment.addToTransactions
-true
if the SDK should add this attachment to everyITransaction
or set tofalse
if it shouldn't.
-
Attachment
public Attachment(@NotNull @NotNull java.lang.String pathname, @NotNull @NotNull java.lang.String filename, @NotNull @NotNull java.lang.String contentType, boolean addToTransactions, @Nullable @Nullable java.lang.String attachmentType)
Initializes an Attachment with a path, a filename, a content type, addToTransactions, and attachmentType.The file located at the pathname is read lazily when the SDK captures an event or transaction not when the attachment is initialized. The pathname string is converted into an abstract pathname before reading the file.
- Parameters:
pathname
- The pathname string of the file to upload as an attachment.filename
- The name of the attachment to display in Sentry.contentType
- The content type of the attachment.addToTransactions
-true
if the SDK should add this attachment to everyITransaction
or set tofalse
if it shouldn't.attachmentType
- The content type of the attachment.
-
-
Method Detail
-
getBytes
@Nullable public @org.jetbrains.annotations.Nullable byte[] getBytes()
Gets the bytes of the attachment.- Returns:
- the bytes.
-
getPathname
@Nullable public @Nullable java.lang.String getPathname()
Gets the pathname string of the attachment.- Returns:
- the pathname string.
-
getFilename
@NotNull public @NotNull java.lang.String getFilename()
Gets the name of the attachment to display in Sentry.- Returns:
- the filename.
-
getContentType
@NotNull public @NotNull java.lang.String getContentType()
Gets the content type of the attachment. Default is "application/octet-stream".- Returns:
- the content type.
-
getAttachmentType
@Nullable public @Nullable java.lang.String getAttachmentType()
Returns the attachmentType type- Returns:
- the attachmentType
-
-