上載影像資產

您擷取在指定時間內有效的上載標記後,即可上載影像資產。以 multipart/form post 形式上載資產,以 URL 查詢字串形式傳送值的其餘部分,如以下範例中所示:

https://s7ugc1.scene7.com/ugc/image?op=upload&upload_token=aa2a378a-cd25-4c80-994d-312094e0ef20_18000&company_name=000Company

upload_token company_name 欄位為必填欄位。

請參閱 擷取上載標記

請參閱 要求共用密鑰

您還可以透過 URL 查詢字串的形式傳送其他可選值,如以下範例所示:

https://s7ugc1.scene7.com/ugc/image?op=upload&upload_token=aa2a378a-cd25-4c80-994d-312094e0ef20_18000&company_name=000Company&file_limit=2000000&file_exts=jpg,gif

file_limit 參數指定檔案大小限制 (以位元組為單位)。 file_exts 參數指定允許上載的文件副檔名。這兩個值都是可選的。

對於允許的檔案大小限制和檔案副檔名,在應用程式中設置全域限制。如果要求中所傳送的內容是全域限制的子集,則允許這一傳送。全域限制如下所示:

全域限制

所有用戶端的檔案大小

20 MB

用於上載的支援影像檔案格式

BMP、GIF、JPG、PNG、PSD

使用者可透過下面的 HTML 表單上載資產。表單要求使用者輸入以下資訊:

  • 公司名稱

  • 上載標記

  • 檔案大小限制

  • 檔案副檔名的清單

  • 待上載檔案的名稱

檢視完整大小的圖形
用於上載資產的 HTML 表單。

當您在瀏覽器視窗中按一下右鍵,然後針對圖中顯示的表單按一下「 檢視來源 」時,將顯示以下 HTML 代碼。代碼顯示當使用者按一下「送出」時執行的對應 URL 查詢字串和 POST 方式。

<html> 
<body> 
    <script language="javascript"> 
        function uploadImage() 
        { 
            var preserve_colorprofile = "false"; 
            if(document.image_upload.preserve_colorprofile[0].checked == true){ 
                preserve_colorprofile = "true"; 
            } 
            var preserve_filename = "false"; 
            if(document.image_upload.preserve_filename[0].checked == true){ 
                preserve_filename = "true"; 
            } 
document.image_upload.action="https://s7ugc1.scene7.com/ugc/image?op=upload&company_name="+document.image_upload.company_name.value+"&upload_token="+document.image_upload.upload_token.value+"&file_limit="+document.image_upload.file_limit.value+"&file_exts="+document.image_upload.file_exts.value+"&preserve_colorprofile="+preserve_colorprofile+"&preserve_filename="+preserve_filename; 
            return true; 
        } 
    </script> 
<form method="POST" enctype="multipart/form-data" name="image_upload" id="image_upload" onSubmit="return uploadImage();"> 
<table> 
<tr><td colspan="2"><strong> UGC Image Upload Test Page: </strong></td></tr> 
<tr><td colspan="2"></td></tr> 
<tr><td><strong> Company Name</strong></td><td><input type="text" size="40" name="company_name"></td></tr> 
<tr><td><strong> Upload Token </strong></td><td><input type="text" size="40" name="upload_token"></td></tr> 
<tr><td><strong> File Size Limit (in bytes) </strong></td><td><input type="text" size="40" name="file_limit">&nbsp;bytes</td></tr> 
<tr><td><strong> File Extensions allowed </strong></td><td><input type="text" size="40" name="file_exts"></td></tr> 
<tr><td><strong> Preserve Color Profile</strong></td><td><input type="radio"  name="preserve_colorprofile" value="true">Yes&nbsp;&nbsp;<input type="radio"  name="preserve_colorprofile" value="false" checked>No</td></tr> 
<tr><td><strong> Preserve File Name</strong></td><td><input type="radio"  name="preserve_filename" value="true">Yes&nbsp;&nbsp;<input type="radio"  name="preserve_filename" value="false" checked>No</td></tr> 
<tr><td colspan="2"></td></tr> 
<tr> 
    <td><strong>File to upload: : </strong></td> 
    <td><input name="filename" type="file" id="filename" size="58" maxlength="1024" /></td> 
</tr> 
<tr><td colspan="2"></td></tr> 
<tr> 
    <td><strong>Click Submit to upload your image: </strong></td> 
    <td><input type="submit" value="Submit"></td> 
</tr> 
</table> 
</form> 
</body> 
</html>

若要在 Internet Explorer 中檢視 XML 回應,請按一下「 檢視 > 原始檔 」。若要在 Firefox 中檢視 XML 回應,請按一下「 檢視 > 網頁原始碼 」。建議使用 Firefox 檢視 XML 回應。

下面是成功上載的範例回應:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?> 
<scene7> 
    <user_generated_content> 
        <response> 
            <serviceName>User Generated Content - Images</serviceName> 
            <version>1.0.0</version> 
            <operationName>upload</operationName> 
            <serviceStatus>SUCCESS</serviceStatus> 
            <title>Your file has been uploaded Successfully.</title> 
            <message> 
            <url>http://s7w2p1.scene7.com/is/image/ </url> 
            <path>000Company/ugc/1442564.tif</path> 
            <fullurl>http://s7w2p1.scene7.com/is/image/000Company/ugc/1442564.tif </fullurl> 
            </message> 
        </response> 
    </user_generated_content> 
</scene7>
備註: 上載的資產 (JPG、GIF 等) 轉換為 PTIFF 格式,回應會傳送該 PTIFF 資產的直接連結。

該資產類似於任何其他的影像伺服資源;您可以對其套用處理查詢。例如,以下 URL 要求延伸到指定寬度和高度的資產。

http://s7w2p1.scene7.com/is/image/S7WebUGC/ugc/9536356.tif?&wid=800&hei=100&fit=stretch

以 multipart/form post 形式傳送要上載的資產,以 URL 查詢字串形式傳送值的其餘部分。您可以在 URL 查詢字串中使用以下欄位來上載資產:

URL 參數

必要或選擇性

op

必要

upload

upload_token

必要

與公司關聯的共用密鑰上載標記。

company_name

必要

執行上載的公司名稱。

file_limit

選擇性

資產的檔案大小限制 (以位元組為單位)。

file_exts

選擇性

影像資產檔案允許的副檔名清單。

preserve_colorprofile

選擇性

用於在將上載檔案轉換成 PTIFF 格式時保留任何內嵌的色彩設定檔。可能的值為 true 或 false。預設為 false。

preserve_filename

選擇性

保留所上載資產的檔案名稱。可能的值為 true 或 false。預設為 false。

備註: 須將待上載資產作為 multipart POST 要求中的唯一欄位傳送。

範例 URL:

https://s7ugc1.scene7.com/ugc/image?op=upload&upload_token=aa2a378a-cd25-4c80-994d-312094e0ef20_18000&company_name=000Company

允許的 HTTP 方式:

POST