Updated on 2023-03-23 GMT+08:00

Uploading a Profile Picture

uploadSelfAvatarWithFilePath:callback:

API Description

This API is used to upload a profile picture.

Precautions

  1. The file path is the profile picture path.
  2. The maximum size is 200 KB.
  3. Only JPG and PNG files are supported.
  4. The recommended aspect ratio is 1:1.
  5. error: Error information. nil: Success.

Method Definition

1
- (void)uploadSelfAvatarWithFilePath:(NSString *_Nullable)filePath callback:(_Nonnull HWMSDKCompleteHandler)callback;

Parameter Description

Table 1

Parameter

Mandatory

Type

Description

filePath

No

NSString *

Profile picture file path.

Return Values

None

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
/// Upload a profile picture.
- (void)uploadSelfAvatar {
    [[HWMBizSdk getBizOpenApi] uploadSelfAvatarWithFilePath:self.headImgPath callback:^(NSError * _Nullable error, id  _Nullable result) {
        if (error) {
            [UIUtil showMessage:[NSString stringWithFormat:@"Failed to upload %@", error.localizedDescription]];
        } else {
            [UIUtil showMessage:@"Upload succeeded."];
        }
    }];
}