Code Monkey home page Code Monkey logo

netshare's Introduction

NetShare

Data sharing in local network

Screenshot 2023-01-11 at 21 39 25

Twitter URL

ko-fi

Demo (Screenshots, Videos)

Mobile

Desktop

Video

NetShare-v2.mp4

How to build the project

Note: This project is mainly running on the latest Flutter beta channel

  1. Run the project as usual
flutter run -d <target-platforms>

<target-platforms> is all supported Flutter platforms, except Web.

Normally, desktop app (macOS, Windows, Linux) will be server and mobile app (Android, iOS) will be client role. But roles can be reversed, let's try and enjoy :)

How to use the app

  1. Build and open app on your target platform as above

For instance, I want to share files between Macbook and Android, so I will build and run app for these platforms. Or you can use released binary files in Releases without building the project.

  1. Connect
  • On Macbook (assume the role of server):
    • Enter the current machine's IP address and port (In 1st time, it will automatically get IP and auto-filled it. Next time, it will use the cached previous connected address).
    • Enter/paste/pick directory location where the files will be hosted.
    • Click on Start hosting button
  • On Android/iOS (assume the role of client):
    • You have two options:
      • Scan to connect to scan the address with QR Code generated by server app (on Mac above)
      • Manual connect to enter address yourself
    • After filling IP/port, press Connect button and enjoy it

Note

  • Remember to connect both server and client app in the same network
  • iOS: To keep iOS app persisting on your device, recommend running it in release mode: flutter run --release (you can not reopen app if running it in debug mode)
  • Run Hive object generator (only when hive (NoSQL Database) has some major changes or the project lacks .g.dart files). By default, all .g.dart files are committed to the repository so you don't need to re-generate again.
flutter pub run build_runner build --delete-conflicting-outputs

netshare's People

Contributors

huynguyennovem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

netshare's Issues

Bug client can not connect: SocketException: No route to host (OS Error: No route to host, errno = 113)

E/flutter (  647): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: SocketException: No route to host (OS Error: No route to host, errno = 113)
E/flutter (  647): #0      _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:719:35)
E/flutter (  647): #1      _NativeSocket.connect (dart:io-patch/socket_patch.dart:982:12)
E/flutter (  647): #2      _RawSocket.connect (dart:io-patch/socket_patch.dart:1865:26)
E/flutter (  647): #3      RawSocket.connect (dart:io-patch/socket_patch.dart:21:23)
E/flutter (  647): #4      Socket._connect (dart:io-patch/socket_patch.dart:2090:22)
E/flutter (  647): #5      Socket.connect (dart:io/socket.dart:750:21)
E/flutter (  647): #6      _ConnectWidgetState._onClickConnect (package:netshare/ui/client/connect_widget.dart:140:35)
E/flutter (  647): #7      _ConnectWidgetState._buildMainLayout.<anonymous closure> (package:netshare/ui/client/connect_widget.dart:94:36)
E/flutter (  647): #8      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1154:21)
E/flutter (  647): #9      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
E/flutter (  647): #10     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:654:11)
E/flutter (  647): #11     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:311:5)
E/flutter (  647): #12     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:281:7)
E/flutter (  647): #13     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:167:27)
E/flutter (  647): #14     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:469:20)
E/flutter (  647): #15     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:445:22)
E/flutter (  647): #16     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:331:11)
E/flutter (  647): #17     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:400:7)
E/flutter (  647): #18     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:363:5)
E/flutter (  647): #19     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:320:7)
E/flutter (  647): #20     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:293:9)
E/flutter (  647): #21     _invoke1 (dart:ui/hooks.dart:186:13)
E/flutter (  647): #22     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:423:7)
E/flutter (  647): #23     _dispatchPointerDataPacket (dart:ui/hooks.dart:119:31)
E/flutter (  647): 

error in main.dart

iconButtonTheme: IconButtonThemeData(style: ButtonStyle(iconColor: MaterialStateProperty.all(Colors.white))),

The named parameter 'iconButtonTheme' isn't defined.

Is this a test to see, that people are looking this project or not 😄 ?

[Bug] When Android as a host/server, it can not list all files that are not media

When using Android device as a terminal for hosting server, some files (not media) (such as apk, pdf) can not be hosted and visible from Client app.

Affected/Tested device: Samsung Galaxy Tab A7 Lite, Android 13

  • This is caused by Directory.list() when hosting file from _getFilesHandler() (implementation level):

    Future<Response> _getFilesHandler(Request request, String address) async {
    // TODO: Blocking by https://github.com/dart-lang/sdk/issues/40303
    // (Hidden files are included)
    List<FileSystemEntity> files = await _pickedDir.value.list().where((f) {
    final fileName = path.basename(f.path);
    if (!fileName.startsWith('.')) return true;
    return false;
    }).toList();

  • Digging dive into this, it's related to Android permission, see dart-lang/sdk#44848 (comment).

There are two options to handle this:

  1. Granting MANAGE_EXTERNAL_STORAGE permission for this OS limitation.
  2. Using privacy-friendly APIs, such as Storage Access Framework or Media Store API (see this).

[SV] Issue when switching to Client mode

Steps to reproduce

  1. Start app on Server mode
  2. Switch to Client mode
  3. There is exception from the output log
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Cannot add new events after calling close
#0      _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24)
#1      Subject._add (package:rxdart/src/subjects/subject.dart:151:17)
#2      Subject.add (package:rxdart/src/subjects/subject.dart:141:5)
#3      new StopWatchTimer.<anonymous closure> (package:stop_watch_timer/stop_watch_timer.dart:57:26)
#4      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#6      _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#7      _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#8      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#9      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#10     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

Release iOS

  • Fixing all bugs
  • Be able to run in release mode (no publishing)

[iOS] can not hosting as server

Steps to reproduce:

  1. Run on iOS
  2. Switch to Server mode
  3. Pick a directory where will host files. file_picker package will returns a path like this:
/private/var/mobile/Containers/Data/Application/8B7FFB5C-AF4F-4ED6-9BFE-3BCB0BD76590/tmp/Share files
  1. Press on Start hosting button

Actual result

That directory does not exist. So flow logic will fall to:

if(!dir.existsSync()) {
  context.showSnackbar('Sharing path does not exist. Try again!');
  return;
}

[iOS] Can not upload file picking from file source

[DocumentManager] Failed to associate thumbnails for picked URL file:///private/var/mobile/Containers/Shared/AppGroup/ABCE53E4-9874-43C8-A3A8-F03F7A02B101/File%20Provider%20Storage/Share%20files/nyancat.gif with the Inbox copy file:///private/var/mobile/Containers/Data/Application/474CB23D-88FB-451E-AA12-2F673C88FD4C/tmp/com.app.netshare-Inbox/nyancat.gif: Error Domain=QLThumbnailErrorDomain Code=102 "(null)" UserInfo={NSUnderlyingError=0x282df67c0 {Error Domain=GSLibraryErrorDomain Code=3 "Generation not found" UserInfo={NSDescription=Generation not found}}}
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PathNotFoundException: Cannot retrieve length of file, path = '/private/var/mobile/Containers/Data/Application/474CB23D-88FB-451E-AA12-2F673C88FD4C/tmp/nyancat.gif' (OS Error: No such file or directory, errno = 2)
#0      _checkForErrorResponse (dart:io/common.dart:55:9)
#1      _File.length.<anonymous closure> (dart:io/file_impl.dart:389:7)
<asynchronous suspension>
#2      multipartFileFromPath (package:http/src/multipart_file_io.dart:17:16)
<asynchronous suspension>
#3      ApiService.uploadFile (package:netshare/data/api_service.dart:41:19)
<asynchronous suspension>
#4      _SendWidgetState._startUploading (package:netshare/ui/send/send_widget.dart:289:20)
<asynchronous suspension>

[C] Open file

Dependency: #14
Only can be opened if file is downloaded/existing on storage

[iOS] can not download file having empty character in name

Steps:

  • Download a file has name: Image from iOS.png
  • File can not be downloaded

Expected result:

File should be downloaded and file state should be done (checked green icon)

Logs

Absolute savedDir path: /var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Documents
execute query: INSERT INTO task (task_id,url,status,progress,file_name,saved_dir,headers,resumable,show_notification,open_file_from_notification,time_created) VALUES ("com.app.netshare.download.task.73493.1691301891.514599","http://192.168.0.4:8080/Image from iOS.png",1,0,"<null>","","%7B%7D",0,1,1,1691301891515)
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
flutter: Callback on background isolate: task (com.app.netshare.download.task.73493.1691301891.514599) is in status (DownloadTaskStatus(1)) and process (0)
Task <B46D7D53-F467-4911-B4F7-F3F49A609613>.<4> finished with error [-1002] Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={_NSURLErrorRelatedURLSessionTaskErrorKey=(
    "BackgroundDownloadTask <B46D7D53-F467-4911-B4F7-F3F49A609613>.<4>"
), NSLocalizedDescription=unsupported URL, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundDownloadTask <B46D7D53-F467-4911-B4F7-F3F49A609613>.<4>}
-[FlutterDownloaderPlugin URLSession:task:didCompleteWithError:] HTTP status code: 0
Download completed with error: unsupported URL
flutter: Callback on background isolate: task (com.app.netshare.download.task.73493.1691301891.514599) is in status (DownloadTaskStatus(4)) and process (-1)
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
flutter: Download taskId: com.app.netshare.download.task.73493.1691301891.514599
flutter: [DownloadService] Download stream log: DownloadEntity(com.app.netshare.download.task.73493.1691301891.514599, Image from iOS.png, http://192.168.0.4:8080/Image from iOS.png, /var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Documents, DownloadManner.flutterDownloader, DownloadState.downloading)
flutter: Fetched files: 41

iOS crashing when hosting file

The fatal crash appears right after selecting a directory to host

“Documents” couldn’t be moved because you don’t have permission to access “tmp”.
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x180d7fc80 0x1985a3ee4 0x180e7a6b4 0x180d19f6c 0x102922a74 0x1839b33a8 0x1833acca8 0x1838b899c 0x183252d8c 0x1834510ec 0x1832b8518 0x1841dc428 0x1832d24e4 0x1831a6cf0 0x1831ba6b8 0x1831ba80c 0x1848a8730 0x180a40094 0x1809ecd44 0x1809ec994 0x180d3b034 0x180cf8538 0x180d0b194 0x1a183e988 0x18350da88 0x1832a6fc8 0x1025617e4 0x1027d04d0)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001bb654bbc libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1bb654bbc <+8>:  b.lo   0x1bb654bd8               ; <+36>
    0x1bb654bc0 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1bb654bc4 <+16>: mov    x29, sp
    0x1bb654bc8 <+20>: bl     0x1bb65060c               ; cerror_nocancel
Target 0: (Runner) stopped.
Lost connection to device.

[iOS] file is downloaded but the state is not updated properly

Steps:

  • Download a file has name: 64499.GD_2021_00101.pdf
  • Check the file is downloaded and located in Files app : On My iPhone > Netshare but the file state in NetShare is still in progressing.

Expected result:

File state should be done (checked green icon)

Logs

flutter: download url: http://192.168.0.4:8080/64499.GD_2021_00101.pdf
Absolute savedDir path: /var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Documents
execute query: INSERT INTO task (task_id,url,status,progress,file_name,saved_dir,headers,resumable,show_notification,open_file_from_notification,time_created) VALUES ("com.app.netshare.download.task.44707.1691301493.602199","http://192.168.0.4:8080/64499.GD_2021_00101.pdf",1,0,"<null>","","%7B%7D",0,1,1,1691301493603)
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
flutter: Download taskId: com.app.netshare.download.task.44707.1691301493.602199
flutter: [DownloadService] Download stream log: DownloadEntity(com.app.netshare.download.task.44707.1691301493.602199, 64499.GD_2021_00101.pdf, http://192.168.0.4:8080/64499.GD_2021_00101.pdf, /var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Documents, DownloadManner.flutterDownloader, DownloadState.downloading)
flutter: Fetched files: 41
flutter: Callback on background isolate: task (com.app.netshare.download.task.44707.1691301493.602199) is in status (DownloadTaskStatus(1)) and process (0)
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
flutter: Callback on background isolate: task (com.app.netshare.download.task.44707.1691301493.602199) is in status (DownloadTaskStatus(2)) and process (42)
flutter: Callback on background isolate: task (com.app.netshare.download.task.44707.1691301493.602199) is in status (DownloadTaskStatus(2)) and process (83)
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
flutter: Callback on background isolate: task (com.app.netshare.download.task.44707.1691301493.602199) is in status (DownloadTaskStatus(2)) and process (100)
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
-[FlutterDownloaderPlugin URLSession:downloadTask:didFinishDownloadingToURL:] HTTP status code: 200
SuggestedFileName: 64499.GD_2021_00101.pdf
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
savedDir: /var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Documents
filename: 64499.GD_2021_00101.pdf
flutter: Callback on background isolate: task (com.app.netshare.download.task.44707.1691301493.602199) is in status (DownloadTaskStatus(3)) and process (100)
[logging-persist] cannot open file at line 45452 of [9ff244ce07]
[logging-persist] os_unix.c:45453: (0) open(/var/mobile/Containers/Data/Application/9562F48F-EB8F-4EFC-B569-7FC6FA6DD35C/Library/Application Support/download_tasks.sql) - Undefined error: 0
Could not execute the query.
-[FlutterDownloaderPlugin URLSession:task:didCompleteWithError:] HTTP status code: 200

[C] Detect if files is downloaded/existing

  • File item can be shown downloading/available state
  • After downloading file, save the entity to database (using Hive)
  • When reopen app/or reconnect devices, all available/downloaded files can be displayed corresponding state

Sharing URL is keeping old domain

Scenario:

  1. Hosting some files on address: 192.168.x.y then stop hosting
  2. Hosting other files on another address: 192.168.a.b
  3. On Client side, select Share file URL menu from itemsy hosted from step 1 (old file)
  4. Check URL is wrong by using old address (192.168.x.y). It should be 192.168.a.b

Actual result:

  • Share the wrong URL (can not open it)
  • Can not download file (loading until timeout)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.