-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.go
More file actions
59 lines (53 loc) · 2.33 KB
/
api.go
File metadata and controls
59 lines (53 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package imx
import (
"io"
)
// Default extractor instance used by package-level functions
var defaultExtractor = New()
// MetadataFromFile extracts metadata from a file path using the default extractor.
//
// The opts parameter accepts functional options to customize extraction behavior.
// Currently available options:
// - WithHTTPTimeout: Has no effect for file operations (only applies to MetadataFromURL)
//
// The opts parameter is provided for API consistency and forward compatibility
// with future configuration options.
func MetadataFromFile(path string, opts ...Option) (*Metadata, error) {
return defaultExtractor.MetadataFromFile(path, opts...)
}
// MetadataFromBytes extracts metadata from a byte slice using the default extractor.
//
// The opts parameter accepts functional options to customize extraction behavior.
// Currently available options:
// - WithHTTPTimeout: Has no effect for byte operations (only applies to MetadataFromURL)
//
// The opts parameter is provided for API consistency and forward compatibility
// with future configuration options.
func MetadataFromBytes(data []byte, opts ...Option) (*Metadata, error) {
return defaultExtractor.MetadataFromBytes(data, opts...)
}
// MetadataFromReader extracts metadata from an io.Reader using the default extractor.
// This buffers data on-demand using a smart adapter that implements io.ReaderAt.
//
// The opts parameter accepts functional options to customize extraction behavior.
// Currently available options:
// - WithHTTPTimeout: Has no effect for reader operations (only applies to MetadataFromURL)
//
// The opts parameter is provided for API consistency and forward compatibility
// with future configuration options.
func MetadataFromReader(r io.Reader, opts ...Option) (*Metadata, error) {
return defaultExtractor.MetadataFromReader(r, opts...)
}
// MetadataFromURL extracts metadata from an HTTP/HTTPS URL using the default extractor.
//
// The opts parameter accepts functional options to customize extraction behavior.
// Available options:
// - WithHTTPTimeout: Sets the HTTP request timeout (default: 30 seconds)
//
// Example:
//
// meta, err := imx.MetadataFromURL("https://example.com/photo.jpg",
// imx.WithHTTPTimeout(60 * time.Second))
func MetadataFromURL(url string, opts ...Option) (*Metadata, error) {
return defaultExtractor.MetadataFromURL(url, opts...)
}