Upload image for Avatar

Hello
on IPhone
I’m trying to upload image to my avatar

The image converted to local file -

/var/mobile/Containers/Data/Application/514B4BF4-FA17-458D-B6FA-5AE063E44BAA/Library/Caches/avatar.jpg
convert by -

      await FileDownloader.downloadFile(
          url: userPhoto,
          name: fileName,
          onProgress: (String? fileName, double progress) {},
          onDownloadError: (String error) async {
            await LoggerActivities.loggerActivity(LoggerActivityModel(user: email, activity: 'AmityServices.file onDownloadError-$error'));

          },
          onDownloadCompleted: (path) {
            final File fileD = File(path);
            file = fileD;
          });

upload by -

  AmityCoreClient
      .newFileRepository()
      .uploadImage(imageFile)
      .stream
      .listen((AmityUploadResult<AmityImage> amityResult) {
    amityResult.when(
      progress: (uploadInfo, cancelToken) {},
      complete: (file) async {
        print('kobi -NupdateUser - 2${file}');
        //handle result

        await LoggerActivities.loggerActivity(LoggerActivityModel(user: email, activity: 'AmityServices.file uploaded'));
        //proceed result with uploadedImage
        updateUserAvatar(file.fileId);
      },
      error: (error) async{
        retCode = false;
        print('kobi -NupdateUser - 2 error $error');
        await LoggerActivities.loggerActivity(LoggerActivityModel(user: email, activity: 'AmityServices.file uploaded error $error'));
      },
      cancel: () {
        // handle cancel request
      },

error - File type is not support

The file type is jpg

Please help me to find the problem

Hi @meridork ,

Surely, may I know which version iOS this is happening on? And doesn’t happen on any other platforms right?

Thank you,
Amity Support

The problem in iOS 16.5.1 android is OK
When I select an image from gallery its working OK

@meridork
May we please have the image file?

Thank you

The file was like following.
Buy I changed the logic to let the user select image from phone or camera and this working OK
const String s1 = ‘https://firebasestorage.googleapis.com/v0/b/aller-17969.appspot.com/o/profileImage%2FopGhHNaUTKdvD7feBIFScl4iDDi1%2F8cc42aa0-215f-11ee-aeab-4d38f67d02b9?alt=media&token=ed552de3-351d-4ede-a599-f6157192198f’;
const String s2 = ‘https://lh3.googleusercontent.com/a/AGNmyxang_1Q-BPxYlfxPFcoMfp61M_ly7eadXMGo-7MSrs=s1337’;

Hello, can you please clarify why you’re using FileDownloader.downloadFile() if you’re pulling images from the local file? It’s possible that the issue is related to the FileDownloader library. The file might need to be saved to the device or converted to image format first before upload to Amity.

1 Like