# uploadImage method Null safety

Future<ImageUploadResult> uploadImage(

1. File? image,
2. Uint8List? byteData,
3. {bool secureResource = true}

)

로컬 이미지를 카카오톡 공유 컨텐츠 이미지로 활용하기 위해 카카오 이미지 서버로 업로드

## Implementation

    Future<ImageUploadResult> uploadImage(File? image, Uint8List? byteData,
        {bool secureResource = true}) async {
      return ApiFactory.handleApiError(() async {
        var formData = FormData();

        final MultipartFile file;

        if (image != null) {
          file = await MultipartFile.fromFile(image.path,
              filename: image.path.split("/").last);
        } else {
          file = MultipartFile.fromBytes(byteData!, filename: "image");
        }
        formData.files.add(MapEntry(Constants.file, file));
        formData.fields
            .add(MapEntry(Constants.secureResource, secureResource.toString()));
        Response response =
            await dio.post(Constants.uploadImagePath, data: formData);
        return ImageUploadResult.fromJson(response.data);
      });
    }