ユーザーのアバターを追加または更新します。
ok
: 更新された既存のユーザーのアバターへのURLを示すpic_urls
オブジェクトを返します。created
: リクエストによってBoxにアップロードされたユーザーのアバターへのURLを示すpic_urls
オブジェクトを返します。bad_request
: 次の場合にエラーを返します。
.jpg
または.png
以外であるforbidden
: アバターをアップロードするために必要な権限がユーザーにない場合、またはユーザーがアクティブになっていない場合にエラーを返します。not_found
: ユーザーが存在しないか見つからない場合にエラーを返します。予期しないクライアントエラー。
curl -i -X -L POST "https://api.box.net/2.0/users/12345/avatar" \
-H "authorization: Bearer <ACCESS_TOKEN>" \
--form 'pic=@"path/to/file/file.jpeg"'
await client.avatars.createUserAvatar(user.id, {
pic: decodeBase64ByteStream(
'iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEW10NBjBBbqAAAAH0lEQVRoge3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAvg0hAAABmmDh1QAAAABJRU5ErkJggg==',
),
picContentType: 'image/png',
picFileName: 'avatar.png',
} satisfies CreateUserAvatarRequestBody);
client.avatars.create_user_avatar(
user.id,
decode_base_64_byte_stream(
"iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEW10NBjBBbqAAAAH0lEQVRoge3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAvg0hAAABmmDh1QAAAABJRU5ErkJggg=="
),
pic_file_name="avatar.png",
pic_content_type="image/png",
)
await client.Avatars.CreateUserAvatarAsync(userId: user.Id, requestBody: new CreateUserAvatarRequestBody(pic: Utils.DecodeBase64ByteStream(data: "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEW10NBjBBbqAAAAH0lEQVRoge3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAvg0hAAABmmDh1QAAAABJRU5ErkJggg==")) { PicContentType = "image/png", PicFileName = "avatar.png" });
String userID = "33333";
BoxUser user = new BoxUser(api, userID);
AvatarUploadResponse response = user.uploadAvatar(new File("path_to_avatar_file"));
avatar_urls = client.user('33333').upload_avatar(image_path='path/to/the/image.png')
using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
{
BoxUploadAvatarResponse response = await client.UsersManager.AddOrUpdateUserAvatarAsync(userId, fileStream);
}
const fs = require('fs');
var readStream = fs.createReadStream('image.jpg');
client.users.setAvatar('22222', readStream).then(result => {
// read avatar urls
});
let image: UIImage = <YOUR_IMAGE_HERE> // Initialize image here e.g. from UIImagePickerController
let data = image.jpegData(compressionQuality: 1)!
client.users.uploadAvatar(userId: "33333", data: data, name: "avatar.jpeg") { result in
guard case let .success(uploadAvatar) = result else {
print("Error uploading user avatar")
return
}
print("User avatar uploaded successfully!")
}
{
"pic_urls": {
"large": "https://app.box.com/index.php?rm=pic_storage_auth&pic=euks\npac3kv01!lipGQlQQOtCTCoB6zCOArUjVWLFJtLr5tn6aOZMCybhRx0NNuFQbVI36nw\njtEk5YjUUz1KVdVuvU2yDhu_ftK_bvxeKP1Ffrx9vKGVvJ-UJc1z32p6n2CmFzzpc\ngSoX4pnPhFgydAL-u9jDspXUGElr-htDG_HPMiE9DZjqDueOxXHy8xe22wbaPAheC\nao1emv8r_fmufaUgSndeMYmyZj-KqOYsLBrBNgdeiK5tZmPOQggAEUmyQPkrd8W92TQ6sSlIp0r",
"preview": "https://app.box.com/index.php?rm=pic_storage_auth&pic=euks!\npac3kv01!8UcNPweOOAWj2DtHk_dCQB4wJpzyPkl7mT5nHj5ZdjY92ejYCBBZc95--403b29CW\nk-8hSo_uBjh5h9QG42Ihu-cOZ-816sej1kof3SOm5gjn7qjMAx89cHjUaNK-6XasRqSNboenjZ\n04laZuV9vSH12BZGAYycIZvvQ5R66Go8xG5GTMARf2nBU84c4H_SL5iws-HeBS4oQJWOJh6FBl\nsSJDSTI74LGXqeZb3EY_As34VFC95F10uozoTOSubZmPYylPlaKXoKWk2f9wYQso1ZTN7sh-Gc\n9Kp43zMLhArIWhok0Im6FlRAuWOQ03KYgL-k4L5EZp4Gw6B7uqVRwcBbsTwMIorWq1g",
"small": "https://app.box.com/index.php?rm=pic_storage_auth&pic=euks! pac3kv01!7B6R5cZLmurEV_xB-KkycPk8Oi7oENUX2O_qUtIuO4342CG IldyCto9hqiQP7uxqYU5V2w63Ft4ln4UVVLDtDZu903OqzkflY2O-Lq00 ubA29xU-RJ6b_KzJEWRYgUhX1zEl3dzWo12g8eWRE2rStf123DF7AYahNqM 1BmLmviL_nODc7SDQHedTXPAjxURUAra5BvtLe7B05AizbNXdPlCNp-LNh _S-eZ_RjDXcGO-MkRWd_3BOMHnvjf450t5BfKoJ15WhEfiMlfXH1tmouHXrsC 66cT6-pzF9E40Iir_zThqSlrFxzP_xcmXzHapr_k-0E2qr2TXp4iC396TSlEw\n"
}
}