Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10525882
attachment.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
attachment.go
View Options
package
activitystreams
import
(
"mime"
"strings"
)
type
Attachment
struct
{
Type
AttachmentType
`json:"type"`
URL
string
`json:"url"`
MediaType
string
`json:"mediaType"`
Name
string
`json:"name"`
}
type
AttachmentType
string
const
(
AttachImage
AttachmentType
=
"Image"
AttachDocument
AttachmentType
=
"Document"
)
// NewImageAttachment creates a new Attachment from the given URL, setting the
// correct type and automatically detecting the MediaType based on the file
// extension.
func
NewImageAttachment
(
url
string
)
Attachment
{
return
newAttachment
(
url
,
AttachImage
)
}
// NewDocumentAttachment creates a new Attachment from the given URL, setting the
// correct type and automatically detecting the MediaType based on the file
// extension.
func
NewDocumentAttachment
(
url
string
)
Attachment
{
return
newAttachment
(
url
,
AttachDocument
)
}
func
newAttachment
(
url
string
,
attachType
AttachmentType
)
Attachment
{
var
fileType
string
extIdx
:=
strings
.
LastIndexByte
(
url
,
'.'
)
if
extIdx
>
-
1
{
fileType
=
mime
.
TypeByExtension
(
url
[
extIdx
:])
}
return
Attachment
{
Type
:
attachType
,
URL
:
url
,
MediaType
:
fileType
,
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 3, 4:34 PM (20 h, 47 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3186433
Attached To
rWC Write.as Web Core
Event Timeline
Log In to Comment