@@ -16,23 +16,34 @@ defprotocol FileStore do
1616 it's usage.
1717 """
1818
19- @ type key :: binary ( )
20- @ type list_opts :: [ { :prefix , binary ( ) } ]
21- @ type delete_all_opts :: [ { :prefix , binary ( ) } ]
19+ @ type key :: String . t ( )
20+
21+ @ type prefix_opt :: { :prefix , String . t ( ) }
22+ @ type content_type_opt :: { :content_type , String . t ( ) }
23+ @ type disposition_opt :: { :disposition , String . t ( ) }
24+ @ type expires_in_opt :: { :expires_in , pos_integer ( ) }
25+
26+ @ type list_opts :: [ prefix_opt ( ) ]
27+ @ type delete_all_opts :: [ prefix_opt ( ) ]
2228 @ type write_opts :: [
23- { :content_type , binary ( ) }
24- | { :disposition , binary ( ) }
29+ content_type_opt ( )
30+ | disposition_opt ( )
31+ ]
32+
33+ @ type upload_opts :: [
34+ content_type_opt ( )
35+ | disposition_opt ( )
2536 ]
2637
2738 @ type public_url_opts :: [
28- { :content_type , binary ( ) }
29- | { :disposition , binary ( ) }
39+ content_type_opt ( )
40+ | disposition_opt ( )
3041 ]
3142
3243 @ type signed_url_opts :: [
33- { :content_type , binary ( ) }
34- | { :disposition , binary ( ) }
35- | { :expires_in , integer ( ) }
44+ content_type_opt ( )
45+ | disposition_opt ( )
46+ | expires_in_opt ( )
3647 ]
3748
3849 @ doc """
@@ -50,7 +61,12 @@ defprotocol FileStore do
5061 :ok
5162
5263 """
53- @ spec write ( t , key , binary , write_opts ) :: :ok | { :error , term }
64+ @ spec write (
65+ store :: t ( ) ,
66+ key :: key ( ) ,
67+ content :: binary ( ) ,
68+ opts :: write_opts ( )
69+ ) :: :ok | { :error , term ( ) }
5470 def write ( store , key , content , opts \\ [ ] )
5571
5672 @ doc """
@@ -62,7 +78,7 @@ defprotocol FileStore do
6278 {:ok, "hello world"}
6379
6480 """
65- @ spec read ( t , key ) :: { :ok , binary } | { :error , term }
81+ @ spec read ( store :: t ( ) , key :: key ( ) ) :: { :ok , binary ( ) } | { :error , term ( ) }
6682 def read ( store , key )
6783
6884 @ doc """
@@ -75,8 +91,13 @@ defprotocol FileStore do
7591 :ok
7692
7793 """
78- @ spec upload ( t , Path . t ( ) , key ) :: :ok | { :error , term }
79- def upload ( store , source , key )
94+ @ spec upload (
95+ store :: t ( ) ,
96+ source :: Path . t ( ) ,
97+ key :: key ( ) ,
98+ opts :: upload_opts ( )
99+ ) :: :ok | { :error , term ( ) }
100+ def upload ( store , source , key , opts \\ [ ] )
80101
81102 @ doc """
82103 Download a file from the store and save it to the given `path`.
@@ -87,7 +108,11 @@ defprotocol FileStore do
87108 :ok
88109
89110 """
90- @ spec download ( t , key , Path . t ( ) ) :: :ok | { :error , term }
111+ @ spec download (
112+ store :: t ( ) ,
113+ key :: key ( ) ,
114+ destination :: Path . t ( )
115+ ) :: :ok | { :error , term ( ) }
91116 def download ( store , key , destination )
92117
93118 @ doc """
@@ -99,7 +124,7 @@ defprotocol FileStore do
99124 {:ok, %FileStore.Stat{key: "foo", etag: "2e5pd429", size: 24}}
100125
101126 """
102- @ spec stat ( t , key ) :: { :ok , FileStore.Stat . t ( ) } | { :error , term }
127+ @ spec stat ( store :: t ( ) , key :: key ( ) ) :: { :ok , FileStore.Stat . t ( ) } | { :error , term ( ) }
103128 def stat ( store , key )
104129
105130 @ doc """
@@ -111,7 +136,7 @@ defprotocol FileStore do
111136 :ok
112137
113138 """
114- @ spec delete ( t , key ) :: :ok | { :error , term }
139+ @ spec delete ( store :: t ( ) , key :: key ( ) ) :: :ok | { :error , term ( ) }
115140 def delete ( store , key )
116141
117142 @ doc """
@@ -130,7 +155,7 @@ defprotocol FileStore do
130155 :ok
131156
132157 """
133- @ spec delete_all ( t , delete_all_opts ) :: :ok | { :error , term }
158+ @ spec delete_all ( store :: t ( ) , opts :: delete_all_opts ( ) ) :: :ok | { :error , term ( ) }
134159 def delete_all ( store , opts \\ [ ] )
135160
136161 @ doc """
@@ -142,7 +167,7 @@ defprotocol FileStore do
142167 :ok
143168
144169 """
145- @ spec copy ( t ( ) , key ( ) , key ( ) ) :: :ok | { :error , term ( ) }
170+ @ spec copy ( store :: t ( ) , src :: key ( ) , dest :: key ( ) ) :: :ok | { :error , term ( ) }
146171 def copy ( store , src , dest )
147172
148173 @ doc """
@@ -156,7 +181,7 @@ defprotocol FileStore do
156181 :ok
157182
158183 """
159- @ spec rename ( t ( ) , key ( ) , key ( ) ) :: :ok | { :error , term ( ) }
184+ @ spec rename ( strore :: t ( ) , src :: key ( ) , dest :: key ( ) ) :: :ok | { :error , term ( ) }
160185 def rename ( store , src , dest )
161186
162187 @ doc """
@@ -173,7 +198,7 @@ defprotocol FileStore do
173198 "https://mybucket.s3-us-east-1.amazonaws.com/foo"
174199
175200 """
176- @ spec get_public_url ( t , key , public_url_opts ) :: binary
201+ @ spec get_public_url ( strore :: t ( ) , key :: key ( ) , opts :: public_url_opts ( ) ) :: String . t ( )
177202 def get_public_url ( store , key , opts \\ [ ] )
178203
179204 @ doc """
@@ -192,7 +217,11 @@ defprotocol FileStore do
192217 {:ok, "https://s3.amazonaws.com/mybucket/foo?X-AMZ-Expires=3600&..."}
193218
194219 """
195- @ spec get_signed_url ( t , key , signed_url_opts ) :: { :ok , binary } | { :error , term }
220+ @ spec get_signed_url (
221+ store :: t ( ) ,
222+ key :: key ( ) ,
223+ opts :: signed_url_opts ( )
224+ ) :: { :ok , binary ( ) } | { :error , term ( ) }
196225 def get_signed_url ( store , key , opts \\ [ ] )
197226
198227 @ doc """
@@ -211,6 +240,6 @@ defprotocol FileStore do
211240 ["foo/bar"]
212241
213242 """
214- @ spec list! ( t , list_opts ) :: Enumerable . t ( )
243+ @ spec list! ( store :: t ( ) , opts :: list_opts ( ) ) :: Enumerable . t ( )
215244 def list! ( store , opts \\ [ ] )
216245end
0 commit comments