jonataslaw / get_server

A backend server that makes it possible to program with Flutter syntax and reuse existing code
Apache License 2.0
476 stars 42 forks source link

how to upload File(image,pdf, etc...) to server #74

Open vimptech-git opened 2 years ago

vimptech-git commented 2 years ago

I am currently using python fast api for backend , now i start learn Get server ,its best solution .now i stuck some functionality, can you pls tell me how to upload files(images,pdf ...) to server folder using getx server...

jonataslaw commented 2 years ago

https://github.com/jonataslaw/get_server/blob/master/example/lib/pages/upload/upload.dart

vimptech-git commented 2 years ago

Can you pls send client side file upload code . Please help me.i try several times Using postman,flutter image upload using multipart request.

On Mon, Mar 7, 2022, 10:33 PM Jonny Borges @.***> wrote:

https://github.com/jonataslaw/get_server/blob/master/example/lib/pages/upload/upload.dart

— Reply to this email directly, view it on GitHub https://github.com/jonataslaw/get_server/issues/74#issuecomment-1060913778, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANO4T6ZEIXZ6QIA2KE44KJTU6YZG5ANCNFSM5QDXZ2OQ . 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: @.***>

tang85 commented 2 years ago

Can you pls send client side file upload code . Please help me.i try several times Using postman,flutter image upload using multipart request. On Mon, Mar 7, 2022, 10:33 PM Jonny Borges @.> wrote: https://github.com/jonataslaw/get_server/blob/master/example/lib/pages/upload/upload.dart — Reply to this email directly, view it on GitHub <#74 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANO4T6ZEIXZ6QIA2KE44KJTU6YZG5ANCNFSM5QDXZ2OQ . 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: @.>


import 'package:path/path.dart' as p;
var dio = Dio(BaseOptions(
  baseUrl: 'http://192.168.1.6:8080',
  connectTimeout: 5000,
  receiveTimeout: 100000,
));

var response = await dio.post(
  '/upload',
  data: FormData.fromMap({
    'file': await MultipartFile.fromFile(filePath, filename: p.basename(filePath)),
  }),
  onSendProgress: (int sent, int total) {
    print('send------$sent/$total');
  },
);