Comments (5)
See the fix in #1496
from flutter_file_picker.
I have exactly the same problem on the web part.
I'm trying to find a solution on my side.
from flutter_file_picker.
Okay I'm back with a solution
Already down to version 6.2.1 because apparently there is a typing error in the file stream
All execution must be in the same method, processing the file and sending the file, the web part of flutter is really very capricious, separated it is two methods would only lose the integrity of the result file by a phenomenon which surpasses me
I had to build a class interface to separate the web part and the app part since the web part is allergic to dart.io
Exemple my code for web :
`
import "package:http/http.dart" as http;
Future setFile(FilePickerResult? result, String typeUpload, String fileUrl) async {
try {
// if file
if (result != null && result.files.isNotEmpty && result.files.single.readStream != null) {
// Uri address
Uri uri = Uri.parse(_urlList.urlPostUploadFile);
/// array post
Map<String, String> requestMap = {
"cible": typeUpload,
};
/// prepare to request file
/// read stream ??? WTF type File ???? baaa it works with this ;)
http.ByteStream stream = http.ByteStream(result.files.single.readStream!.asBroadcastStream());
/// Include multiparte file
var request = http.MultipartRequest('POST', uri);
request.fields.addAll(requestMap);
request.files.add(http.MultipartFile(
'file',
stream,
result.files.first.size,
filename: result.files.first.name,
));
/// Post file
var response = await request.send();
if (response.statusCode == 200) {
/// Lecture des données - retour serveur
String responseString = await response.stream.bytesToString();
print("REPONSE : $responseString");
/// Décodage des données json
var jsonData = jsonDecode(responseString);
_setInfo = CtrlUploadData.fromJson(jsonData);
/// check code info
if (_setInfo.returnCode != 0 && _setInfo.returnCode <= 8) {
return false;
} else {
return true;
}
} else {
return false;
}
} else {
return false;
}
} catch (ex) {
return false;
}
`
We really need to make an effort to clarify and enter into a standardized convention, the backtracking in this part of the code has been numerous on my side and the doc is not at all in line with what is happening concretely.
I spent some time on this and made the effort to detail everything, I hope this will be taken into account in the next patch
Sorry but it's frustrating for me to see this error several times
in particular it is the typing problem of result.files.first.readStream which poses recurring problems.
More info on this and clear documentation would not be refused.
Sorry for my English, best regards
from flutter_file_picker.
I would at least like to have a response from you before you close this thread ?!
Best regards
from flutter_file_picker.
Thanks
from flutter_file_picker.
Related Issues (20)
- Migrate to `package:web` to support WASM HOT 4
- Problem for Web - having to use FilePickerWeb is not documented HOT 2
- Web:Uncaught Unsupported operation: Platform._operatingSystem HOT 3
- File Picker Get Directory Crash on IOS Real Device ... HOT 2
- Compilation fails with Pod::PICKER_DOCUMENT = false HOT 5
- Support for initialDirectory on Android/mobile HOT 2
- Prefilter items displayed via arbitrary filename/foldername filter HOT 2
- Return file metedata in a timely manner HOT 2
- [Android] app crashes when using `getDirectoryPath()` or `saveFile()` HOT 4
- Add webp to FileType.image
- Reimplement macos file picker using native APIs in the app rather than calling out to osascript HOT 3
- Reimplement linux file picker using native APIs in the app rather than calling out to zenity
- Changes 'dart:html' to 'universal:html' HOT 1
- [iOS] Hide DRM protected files for Apple Music picker HOT 2
- Feature request: add an option parameter to return the original path and avoid caching the file (for Android/iOS). HOT 2
- The application closes when selecting an image HOT 1
- Property with 'retain (or strong)' attribute must be of object type HOT 5
- Update regarding DKImagePickerController/PhotoGallery of Privacy Manifest? HOT 5
- After drag and drop image when trying select image to upload there is no way handle selected image HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_file_picker.