File tree Expand file tree Collapse file tree 4 files changed +21
-8
lines changed
demos/supabase-todolist/lib/attachments
packages/powersync_core/test/attachments Expand file tree Collapse file tree 4 files changed +21
-8
lines changed Original file line number Diff line number Diff line change
1
+ import 'package:path_provider/path_provider.dart' ;
2
+ import 'package:powersync_core/attachments/attachments.dart' ;
3
+ import 'package:powersync_core/attachments/io.dart' ;
4
+
5
+ Future <LocalStorage > localAttachmentStorage () async {
6
+ final appDocDir = await getApplicationDocumentsDirectory ();
7
+ return IOLocalStorage (appDocDir);
8
+ }
Original file line number Diff line number Diff line change
1
+ import 'package:powersync_core/attachments/attachments.dart' ;
2
+
3
+ Future <LocalStorage > localAttachmentStorage () async {
4
+ // This file is imported on the web, where we don't currently have a
5
+ // persistent local storage implementation.
6
+ return LocalStorage .inMemory ();
7
+ }
Original file line number Diff line number Diff line change 1
1
import 'dart:async' ;
2
- import 'dart:io' ;
3
2
4
3
import 'package:logging/logging.dart' ;
5
- import 'package:path_provider/path_provider.dart' ;
6
4
import 'package:powersync/powersync.dart' ;
7
5
import 'package:powersync_core/attachments/attachments.dart' ;
8
- import 'package:powersync_core/attachments/io.dart' ;
9
6
10
7
import 'package:powersync_flutter_demo/attachments/remote_storage_adapter.dart' ;
11
8
9
+ import 'local_storage_unsupported.dart'
10
+ if (dart.library.io) 'local_storage_native.dart' ;
11
+
12
12
late AttachmentQueue attachmentQueue;
13
13
final remoteStorage = SupabaseStorageAdapter ();
14
14
final logger = Logger ('AttachmentQueue' );
15
15
16
16
Future <void > initializeAttachmentQueue (PowerSyncDatabase db) async {
17
- // Use the app's document directory for local storage
18
- final Directory appDocDir = await getApplicationDocumentsDirectory ();
19
-
20
17
attachmentQueue = AttachmentQueue (
21
18
db: db,
22
19
remoteStorage: remoteStorage,
23
20
logger: logger,
24
- localStorage: IOLocalStorage (appDocDir ),
21
+ localStorage: await localAttachmentStorage ( ),
25
22
watchAttachments: () => db.watch ('''
26
23
SELECT photo_id as id FROM todos WHERE photo_id IS NOT NULL
27
24
''' ).map (
Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ void main() {
24
24
.map (
25
25
(rs) => [
26
26
for (final row in rs)
27
- WatchedAttachmentItem (id: row[0 ] as String , fileExtension: 'jpg' )
27
+ WatchedAttachmentItem (
28
+ id: row['photo_id' ] as String , fileExtension: 'jpg' )
28
29
],
29
30
);
30
31
}
You can’t perform that action at this time.
0 commit comments