Silicon Valley Fishkeeping
Sign In
Language

Flutter Image upload to S3 with signed url

0
2294
#flutter #dio #s3 upload #aws

I've struggled a bit to figure out how to convert Uint8List to data that dio client expects.


Here is my code.


Basically you should

http.ByteStream.fromBytes(int8List)


to convert Int8List bytes to Stream<List<int>>.


aquadesk in article adsense





import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;


aquadesk in article adsense



try {
  // get signed url
  Response response = await dio.get(
      '$apiUrl/s3/sign?objectName=app-test.png&contentType=image%2Fpng&path=dev%2Ftanks%2FDDuMahcPGO%2F');

  final String signedUrl = response.data["signedUrl"];

  // get data stream
  Uint8List int8List = await rootBundle
      .load('assets/fish/1.png')
      .then((value) => value.buffer.asUint8List());

  Response uploadRes = await dio.put(
    signedUrl,
    data: http.ByteStream.fromBytes(int8List),
    onSendProgress: (int sentBytes, int totalBytes) {
      double progressPercent = sentBytes / totalBytes * 100;
      print("upload $progressPercent %");
    },
    options: Options(
      contentType: "image/png",
      headers: {
        "Content-Length": int8List.length,
      },
    ),
  );

  print("uploadRes.statusCode, ${uploadRes.statusCode}");
  // 200 success
} catch (e) {
  print(e);
}



aquadesk in article adsense



Comments

    No comments.

Back

More to read

Flutter facebook, google social sign-in, login key hash problem
flutter, social login, google, facebook, key hash, facebook console, firebase console
eFISHient
If you see this screen, you'd have to get key hash from the development computer and put it in facebook dev console. Invalid key hash. The key hash sL1***************VY= does not match any stored key hashes. Configure your app key hashes at http://developers.facebook.com/apps/150*******778
플러터 개발 중 ios 기기에 배포 시 오류 발생 해결법
flutter, 플러터, ios
Aquadesk
아래 와 같은 오류가 발생 하는 경우 SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; 코드에서 이렇게 된 부분을 모두 찾아서 SUPPORTED_PLATFORMS = iphoneos 이렇게 변경해주면 빌드가 됩니다. Running pod install...                                              3.4s Running Xcode build... Xcode build done.                       
Solving an error when you build flutter app for ios device
ios, flutter, build error, xcode
Aquadesk
Running pod install...                                              3.4s Running Xcode build... Xcode build done.                                            8.3s Failed to build iOS app Error output from Xcode build: ↳     2022-02-24 13:44:32.345 xcodebuild[7577:6161460]  DVTAssertions: Warning in
3D 프린터로 DIY 자작 브라인쉬림프 거름망 만들기
3D 프린터, DIY프로젝트, 물생활 자작, 브라인쉬림프
eFISHient
3D 프린터로 DIY 자작 브라인쉬림프 거름망 만들기 안녕하세요 최근에 제 디스커스가 번식을 해서 새끼를 엄청 낳았어요. 디스커스 새끼들 브라인 슈림프 정말 많이 먹어요. 정말 상상 초월이에요 ㅎㅎ 그래서 브라인 슈림프 부화 관련해서 많은 용품이 필요 했는데요.  그 중 몇가지는 3D 프린트를 이용해서 만들어 봤어요.  DIY 브라인 쉬림프 거름망 - 3D 프린터기로 만들기 - 3분 정리 각 단계별로 더 자세한 내용이 궁금하시면 아래 각각의 영상과 내용을
L18 golden nugget pleco 해외 포럼에서 퍼왔어요 번역
골든 너겟 플레코, golden nugget pleco, 번역본, 물고기도감
eFISHient
해외 포럼에서 퍼왔어요 너무 이뻐서리 ㅠㅠ 골든 너겟 플레코 설명 Description of Golden Nugget Pleco Fish  몸에 노란점이 있고 등지느러미, 꼬리지느러미 끝에 노란색 테가 있는 골든 플레코. 유어는 성별 구분이 불가하다. 그러나 성어 암컷은 날씬하고 이마가 동글동글 하다. 요 녀석들이 새끼칠 무렵이 되면, 바닥을 파는 성향을 보인다. 산란상이나 구멍에 알을 낳는다. 에어스톤옆에 부드러운 물과 풍부한 산소량은 부화에 도움이 된다.
토마시 플레코 L188a 생태 번역
해외자료, 토마시플레코, L188a, 열대어도감
eFISHient
https://www.aquadesk.com 아름다운 열대어 사진, 비디오, 정보   토마시 플레코는 남아메리카의 강이나 지류에 서식합니다. 몸통은 밝은 갈색 혹은 금색이고 비늘은 테두리가 검은갈색으로 되어 있어 튼튼한 갑옷을 입은 모습을 보여줍니다. 토마시 플레코는 합사항에 잘 어울리는 물고기가 될거에요. The Thomasi Plecostomus comes from the rivers and tributaries of South America. The body is light brown to gold w
2017 SimplyDiscus 국제 온라인 디스커스 사진 대회
디스커스 사진대회, simply discus, 심플리디스커스, 사진대회, 디스커스, discus
eFISHient
2017/4/2 부터 접수를 받는다고 하고  이메일을 통해 접수를 받는다고 하네요. 이메일은 추후 공지한다고 합니다. 접수를 위해서는 준수해야하는 규칙이 있고 접수되는 이미지는 정면 좌우 측면 그리고 자 위에 올려두고 찍은 사진 이렇게 4장을 보내야 한다네요. ----  http://forum.simplydiscus.com/showthread.php?128217-International-Online-Discus-show-Coming-soon-%C9%AA-Discus-2017&p=1256693#pos

Back