@@ -171,12 +171,18 @@ class FileSystemProviderObjectStore extends ObjectStore {
171171 @override
172172 final uploadsSupported = false ;
173173
174- // TODO Make port configurable
175- final httpServerConfig = {
176- 'port' : 23432 ,
177- };
178-
179- FileSystemProviderObjectStore (this .node, {required this .localDirectories}) {
174+ final String externalDownloadUrl;
175+
176+ final int httpPort;
177+ final String httpBind;
178+
179+ FileSystemProviderObjectStore (
180+ this .node, {
181+ required this .localDirectories,
182+ required this .httpPort,
183+ required this .httpBind,
184+ required this .externalDownloadUrl,
185+ }) {
180186 final app = Alfred ();
181187
182188 app.all ('*' , cors ());
@@ -186,11 +192,13 @@ class FileSystemProviderObjectStore extends ObjectStore {
186192 if (metadataHashes.containsKey (hash)) {
187193 res.add (metadataHashes[hash]! );
188194 res.close ();
195+ } else if (fileHashes.containsKey (hash)) {
196+ return File (fileHashes[hash]! );
189197 }
190198 });
191199 app.listen (
192- httpServerConfig[ 'port' ] ! ,
193- httpServerConfig[ 'bind' ] ?? '0.0.0.0' ,
200+ httpPort ,
201+ httpBind ,
194202 );
195203 }
196204
@@ -210,9 +218,9 @@ class FileSystemProviderObjectStore extends ObjectStore {
210218 Future <StorageLocation > provide (Multihash hash, List <int > types) async {
211219 return StorageLocation (
212220 3 ,
213- // TODO Specify external URL and increase expiry
214- ['http://localhost:23432 /hash/${hash .toBase64Url ()}' ],
215- calculateExpiry (Duration (seconds : 30 )),
221+ // TODO Increase expiry
222+ ['$ externalDownloadUrl /hash/${hash .toBase64Url ()}' ],
223+ calculateExpiry (Duration (minutes : 10 )),
216224 );
217225 }
218226
0 commit comments