upload method

Future<String?> upload({
  1. required BuildContext context,
  2. dynamic progress(
    1. double
    )?,
  3. dynamic complete()?,
  4. int compressQuality = 80,
  5. String? saveAs,
  6. bool camera = true,
  7. bool gallery = true,
  8. double maxHeight = 1024,
  9. double maxWidth = 1024,
})

Update photos in the Firebase Storage.

사용자에게 사진/파일 업로드를 요청한다.

  1. It displays the upload source selection dialog (camera or gallery).
  2. It picks the file
  3. It compresses the file
  4. It uploads and calls back the function for the progress indicator.
  5. It returns the download url of the uploaded file.

If the user cancels the upload, it returns null.

Ask user to upload a photo or a file

Call this method when the user presses the button to upload a photo or a file.

This method does not handle any exception. You may handle it outisde if you want.

path is the file path on mobile phone(local storage) to upload.

saveAs is the path on the Firebase storage to save the uploaded file. If it's empty, it willl save the file under "/users/$uid/". You can use this option to save the file under a different path.

compressQuality is the quality of the compress for the image before uploading.

camera is a flag to allow the user to choose the camera as the source.

gallery is a flag to allow the user to choose the gallery as the source.

maxHeight is the maximum height of the image to upload.

maxWidth is the maximum width of the image to upload.

It returns the download url of the uploaded file.

Implementation

Future<String?> upload({
  required BuildContext context,
  Function(double)? progress,
  Function()? complete,
  int compressQuality = 80,
  String? saveAs,
  bool camera = true,
  bool gallery = true,
  double maxHeight = 1024,
  double maxWidth = 1024,
}) async {
  return await uploadFrom(
    context: context,
    source: await chooseUploadSource(
      context: context,
      camera: camera,
      gallery: gallery,
    ),
    progress: progress,
    complete: complete,
    compressQuality: compressQuality,
    saveAs: saveAs,
    maxHeight: maxHeight,
    maxWidth: maxWidth,
  );
}