Open vimptech-git opened 2 years ago
Try this: Uint8List bytes = base64.decode(upload!.data); ... p.writeAsBytes(bytes);
class FileuploadView extends GetView { @override Widget build(BuildContext context) { return MultiPartWidget( builder: (context, upload) { final path = 'images/123.jpg'; var p = File(path); Uint8List bytes = base64.decode(upload!.data); p.writeAsBytes(bytes);
return Json({'filename': upload.data});
},
);
} } /////////////////////////////////////////////////////////// showing following error Unhandled exception: type 'Uint8List' is not a subtype of type 'String' ///////////////////////////////////////////////// Note:- at the time of testing fist time image successfully upload .. then second time file uploaded successfully but can't open file then we try again and again then some time image upload success.. Pls Help me ..... my suggestion can i use awit p.writeAsBytes(bytes); in this time builder method show error due to async /////////////////////////////////////////////////////////
[image: Capture.JPG]
On Thu, Mar 10, 2022 at 10:21 PM Jonny Borges @.***> wrote:
Try this: Uint8List bytes = base64.decode(upload!.data); ... p.writeAsBytes(bytes);
— Reply to this email directly, view it on GitHub https://github.com/jonataslaw/get_server/issues/77#issuecomment-1064280321, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANO4T67VPIVA3DWHWHTWFK3U7ISCTANCNFSM5QNAZ5EA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
Succeed when the image has small size .Always failed when the image was big(>2M). This can be reproduced as image in postman.
and codes as :
MultiPartWidget(
name: 'image',
builder: (context, upload)
if (upload != null) {
var data = upload.data;
print('---receive---${data.length}');
File(upload.name ?? 'empty_name.png').writeAsBytesSync(data);
return Json({'name': upload.name ?? 'empty_name.png'});
} else {
return Json({'name': 'error'});
}
});
import 'dart:io';
import 'package:get_server/get_server.dart';
class FileuploadView extends GetView { @override Widget build(BuildContext context) { return MultiPartWidget( builder: (context, upload) { final path = 'images/123.jpg'; var p = File(path); p.writeAsBytes(upload!.data);
} }