

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 WorkSpaces Personal 中自訂品牌
<a name="customize-branding"></a>

Amazon WorkSpaces 可讓您使用 API 以自有品牌標誌、IT 支援資訊、忘記密碼連結和登入訊息來自訂 WorkSpace 登入頁面的外觀，讓您為使用者建立熟悉的 WorkSpaces 體驗。您的品牌會在使用者的 WorkSpace 登入頁面中顯示，而不是顯示預設的 WorkSpaces 品牌。

支援的用戶端如下：
+ Windows
+ Linux
+ Android
+ MacOS
+ iOS
+ Web Access

## 匯入自訂品牌
<a name="import-custom-branding"></a>

若要匯入您的用戶端品牌自訂，請使用動作 `ImportClientBranding`，其中包含下列元素。如需詳細資訊，請參閱 [ImportClientBranding API 參考](https://docs.aws.amazon.com/workspaces/latest/api/API_ImportClientBranding.html)。

**重要**  
用戶端品牌屬性為公眾面向。確保您不包含敏感資訊。

根據您的目錄是否使用舊版或新使用者登入流程，您的使用者將看到您的自訂用戶端品牌屬性，如以下螢幕擷取畫面所示。


|  |  | 
| --- |--- |
|  ![\[WorkSpaces 用戶端登入畫面 - 舊版登入流程\]](http://docs.aws.amazon.com/zh_tw/workspaces/latest/adminguide/images/client-cobranding-legacy.png)  |  ![\[WorkSpaces 用戶端登入畫面 - 新的登入流程\]](http://docs.aws.amazon.com/zh_tw/workspaces/latest/adminguide/images/client-cobranding-new.png)  | 

1. 支援連結

1. 標誌

1. 忘記密碼連結

1. 登入訊息


**自訂品牌元素**  

| 品牌元素 | Description | 要求和建議 | 
| --- | --- | --- | 
| 支援連結 | 可讓您指定支援電子郵件連結，供使用者聯絡以尋求其 WorkSpaces 的協助。您可以使用 SupportEmail 屬性，或使用 SupportLink 屬性提供支援頁面的連結。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/workspaces/latest/adminguide/customize-branding.html) | 
| 標誌 | 可讓您使用 Logo 屬性來自訂貴組織的標誌。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/workspaces/latest/adminguide/customize-branding.html) | 
| 忘記密碼連結 | 可讓您使用 ForgotPasswordLink 屬性來新增網址，如果使用者忘記了自己的 WorkSpace 密碼，就可以前往該屬性。 | 長度限制：長度下限為 1。長度上限為 200。 | 
| 登入訊息 | 可讓您使用登入畫面上的 LoginMessage 屬性來自訂訊息。 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/workspaces/latest/adminguide/customize-branding.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/workspaces/latest/adminguide/customize-branding.html)  | 

以下是使用 ImportClientBranding 的範例程式碼片段。

### AWS CLI 第 2 版
<a name="import-client-branding-cli"></a>

**警告**  
匯入自訂商標會覆寫該平台內您使用自訂資料指定的屬性。也會覆寫您未使用預設自訂品牌屬性值指定的屬性。您必須包含您不想覆寫之任何屬性的資料。

```
aws workspaces import-client-branding \
--cli-input-json file://~/Downloads/import-input.json \
--region us-west-2
```

匯入 JSON 檔案看起來應該如下列範例程式碼所示：

```
{
    "ResourceId": "<directory-id>",
    "DeviceTypeOsx": {
        "Logo": "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAC0lEQVR42mNgQAcAABIAAeRVjecAAAAASUVORK5CYII=",
        "ForgotPasswordLink": "https://amazon.com/",
        "SupportLink": "https://amazon.com/",
        "LoginMessage": {
            "en_US": "Hello!!"
        }
    }
}
```

下列範例 Java 程式碼片段會將標誌影像轉換為 base64 編碼字串：

```
// Read image as BufferImage
BufferedImage bi = ImageIO.read(new File("~/Downloads/logo.png"));
   
// convert BufferedImage to byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "png", baos);
byte[] bytes = baos.toByteArray();
       
//convert byte[] to base64 format and print it
String bytesBase64 = Base64.encodeBase64String(bytes);
System.out.println(bytesBase64);
```

下列範例 Python 程式碼片段會將標誌影像轉換為 base64 編碼字串：

```
# Read logo into base64-encoded string
with open("~/Downloads/logo.png", "rb") as image_file:
    f = image_file.read()
    base64_string = base64.b64encode(f)
    print(base64_string)
```

### Java
<a name="import-client-branding-java"></a>

**警告**  
匯入自訂商標會覆寫該平台內您使用自訂資料指定的屬性。也會覆寫您未使用預設自訂品牌屬性值指定的屬性。您必須包含您不想覆寫之任何屬性的資料。

```
// Create WS Client
WorkSpacesClient client = WorkSpacesClient.builder().build();

// Read image as BufferImage
BufferedImage bi = ImageIO.read(new File("~/Downloads/logo.png"));

// convert BufferedImage to byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "png", baos);
byte[] bytes = baos.toByteArray();
    
// Create import attributes for the plateform 
DefaultImportClientBrandingAttributes attributes =
        DefaultImportClientBrandingAttributes.builder()
                .logo(SdkBytes.fromByteArray(bytes))
                .forgotPasswordLink("https://aws.amazon.com/")
                .supportLink("https://aws.amazon.com/")
                .build();
                    
// Create import request
ImportClientBrandingRequest request = 
        ImportClientBrandingRequest.builder()
                .resourceId("<directory-id>")
                .deviceTypeOsx(attributes)
                .build();
                    
// Call ImportClientBranding API
ImportClientBrandingResponse response = client.importClientBranding(request);
```

### Python
<a name="import-client-branding-python"></a>

**警告**  
匯入自訂商標會覆寫該平台內您使用自訂資料指定的屬性。也會覆寫您未使用預設自訂品牌屬性值指定的屬性。您必須包含您不想覆寫之任何屬性的資料。

```
import boto3

# Read logo into bytearray
with open("~/Downloads/logo.png", "rb") as image_file:
    f = image_file.read()
    bytes = bytearray(f)

# Create WorkSpaces client
client = boto3.client('workspaces')

# Call import API
response = client.import_client_branding(
    ResourceId='<directory-id>',
    DeviceTypeOsx={
        'Logo': bytes,
        'SupportLink': 'https://aws.amazon.com/',
        'ForgotPasswordLink': 'https://aws.amazon.com/',
        'LoginMessage': {
            'en_US': 'Hello!!'
        }
    }
)
```

### PowerShell
<a name="import-client-branding-powershell"></a>

```
#Requires -Modules @{ ModuleName="AWS.Tools.WorkSpaces"; ModuleVersion="4.1.56"}

# Specify Image Path
$imagePath = "~/Downloads/logo.png"

# Create Byte Array from image file
$imageByte = ([System.IO.File]::ReadAllBytes($imagePath))

# Call import API
Import-WKSClientBranding -ResourceId <directory-id> `
    -DeviceTypeLinux_LoginMessage @{en_US="Hello!!"} `
    -DeviceTypeLinux_Logo $imageByte `
    -DeviceTypeLinux_ForgotPasswordLink "https://aws.amazon.com/" `
    -DeviceTypeLinux_SupportLink "https://aws.amazon.com/"
```

若要預覽登入頁面，請啟動 WorkSpaces 應用程式或 Web 登入頁面。

**注意**  
變更可能需要多達 1 分鐘的時間才會出現。

## 描述自訂品牌
<a name="describe-custom-branding"></a>

若要查看您目前擁有之用戶端品牌自訂的詳細資料，請使用動作 `DescribeCustomBranding`。以下是使用 DescribeClientBranding 的範例指令碼。如需詳細資訊，請參閱 [DescribeClientBranding API 參考](https://docs.aws.amazon.com/workspaces/latest/api/API_DescribeClientBranding.html)。

```
aws workspaces describe-client-branding \
--resource-id <directory-id> \
--region us-west-2
```

## 刪除自訂品牌
<a name="delete-custom-branding"></a>

若要刪除您的用戶端品牌自訂，請使用動作 `DeleteCustomBranding`。以下是使用 DeleteClientBranding 的範例指令碼。如需詳細資訊，請參閱 [DeleteClientBranding API 參考](https://docs.aws.amazon.com/workspaces/latest/api/API_DeleteClientBranding.html)。

```
aws workspaces delete-client-branding \ 
--resource-id <directory-id> \
--platforms DeviceTypeAndroid DeviceTypeIos \  
--region us-west-2
```

**注意**  
變更可能需要多達 1 分鐘的時間才會出現。