KasemJaffer / receive_sharing_intent

A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.
Apache License 2.0
334 stars 391 forks source link

Upload multiple files to a nodejs server #189

Open vancuf opened 2 years ago

vancuf commented 2 years ago

How do I format the links to upload multiple files to a NodeJS server? So far I can only upload files one by one. the URLs format for multiple share is one long URL "/data/user/0/com.example.share_app/cache/20210615_213948.jpg,/data/user/0/com.example.share_app/cache/Screenshot_2018-05-11-20-38-25.png"

This is the dio.dart uploader I am using, it can only upload one file at a time. uploadFile(filename) async { var formData = FormData(); formData.files.addAll([ MapEntry( "files", MultipartFile.fromFileSync( _sharedFiles?.map((f) => f.path)?.join(",") ?? "")) ]); Response response = await Dio().post("http://192.168.0.7:3000/upload", data: formData); print(response.toString()); }

GourabPaul007 commented 2 years ago

this is not this package specific question?

but you can run a for loop for every file path in _sharedFiles and add the links to a list. may be this can help you https://stackoverflow.com/a/63269887

vancuf commented 2 years ago

this is not this package specific question?

but you can run a for loop for every file path in _sharedFiles and add the links to a list. may be this can help you https://stackoverflow.com/a/63269887

The stackover link not working.

GourabPaul007 commented 2 years ago

this should work https://stackoverflow.com/questions/63263840/how-to-upload-multiple-images-files-in-flutter-using-dio/63269887#63269887

vancuf commented 2 years ago

this should work https://stackoverflow.com/questions/63263840/how-to-upload-multiple-images-files-in-flutter-using-dio/63269887#63269887

Yes this works with one url but the problem i am having is breaking up multiple urls "/data/user/0/com.example.share_app/cache/20210615_213948.jpg,/data/user/0/com.example.share_app/cache/Screenshot_2018-05-11-20-38-25.png" then uploading with dio

GourabPaul007 commented 2 years ago

you can split the string with String's split(","); method. Or better - dont merge the string in first place. make a list of string and when maping through the _sharedFiles, add each file path to the list.

bhagat-techind commented 1 year ago

You can use my plugin flutter_sharing_intent