Tüm Ürünler
Search
Belge Merkezi

Object Storage Service:Document snapshots

Son Güncelleme:Oct 13, 2026

Belge anlık görüntüsü özelliğini kullanarak Word, Excel, PPT veya PDF gibi bir belgenin belirli bir sayfasının anlık görüntüsünü, dosyayı indirmeden cloud üzerinde oluşturabilirsiniz. Bu özellik, web sayfasına gömme ve veri yedekleme gibi çeşitli senaryoları destekler.

Kullanım Senaryoları

  • Veri yedekleme ve kurtarma: Veri yedekleme amacıyla Object Storage Service (OSS) paketlerinizdeki belgelerin anlık görüntülerini periyodik olarak oluşturabilirsiniz.

  • Anahtar bilgilerin çıkarılması: Anahtar bilgileri hızlıca çıkarmak için belirli bir sayfayı yakalamak üzere belge anlık görüntülerini kullanabilirsiniz.

Özelliği kullanma

Önkoşullar

Object Storage Service (OSS) içinde bir paket oluşturmanız, işlenecek belgeyi pakete yüklemeniz ve pakete bir Intelligent Media Management (IMM) projesi eklemeniz gerekir. IMM projesi, paket ile aynı bölgede olmalıdır.

Belge anlık görüntüleri

İşleme için belge anlık görüntüsü API'sini çağırmak üzere bir SDK kullanabilirsiniz.

Java

package com.aliyun.oss.demo;
import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import java.net.URL;
import java.util.Date;

public class Demo {
    public static void main(String[] args) throws Throwable {
        // The China (Hangzhou) region is used as an example. Set the Endpoint to the actual region.
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // Obtain access credentials from environment variables. Before running this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // Specify the bucket name, for example, examplebucket.
        String bucketName = "examplebucket";
        // Specify the full path of the object. If the document is not in the root directory of the bucket, you must include the full path, for example, exampledir/demo.docx.
        String objectName = "demo.docx";
        // Specify the region where the bucket is located. The China (Hangzhou) region is used as an example. Set the region to cn-hangzhou.
        String region = "cn-hangzhou";

        // Create an OSSClient instance.
        // When the OSSClient instance is no longer needed, call the shutdown method to release resources.
        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(credentialsProvider)
                .clientConfiguration(clientBuilderConfiguration)
                .region(region)
                .build();

        try {
            // Build the document snapshot processing instruction to get a snapshot of the second page of the document.
            String style = "doc/snapshot,target_jpg,source_docx,page_2";
            // Set the expiration time of the signed URL to 3,600 seconds.
            Date expiration = new Date(new Date().getTime() + 3600 * 1000L);
            GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, objectName, HttpMethod.GET);
            req.setExpiration(expiration);
            req.setProcess(style);
            URL signedUrl = ossClient.generatePresignedUrl(req);
            System.out.println(signedUrl);
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

Python

# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider

# Obtain access credentials from environment variables. Before running this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())

# Specify the bucket name.
bucket = 'examplebucket'

# Specify the Endpoint for the region where the bucket is located. The China (Hangzhou) region is used as an example.
endpoint = 'https://oss-cn-hangzhou.aliyuncs.com'

# Specify the general-purpose Alibaba Cloud region ID.
region = 'cn-hangzhou'
bucket = oss2.Bucket(auth, endpoint, bucket, region=region)

# Specify the source document name. If the document is not in the root directory of the bucket, you must include the full path, for example, exampledir/demo.docx.
key = 'demo.docx'

# Specify the expiration time in seconds.
expire_time = 3600

# Build the document snapshot processing instruction to get a snapshot of the second page of the document.
process = 'doc/snapshot,target_jpg,source_docx,page_2 '

# Generate a signed URL with image processing parameters.
url = bucket.sign_url('GET', key, expire_time, params={'x-oss-process': process}, slash_safe=True)

# Print the signed URL.
print(url)

Go

package main

import (
	"fmt"
	"os"

	"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

func HandleError(err error) {
	fmt.Println("Error:", err)
	os.Exit(-1)
}

func main() {
	// Obtain access credentials from environment variables. Before running this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
	provider, err := oss.NewEnvironmentVariableCredentialsProvider()
	if err != nil {
		fmt.Println("Error:", err)
		os.Exit(-1)
	}

	// Create an OSSClient instance.
	// Set yourEndpoint to the Endpoint of the bucket. The China (Hangzhou) region is used as an example. Set the Endpoint to https://oss-cn-hangzhou.aliyuncs.com. Set other regions as needed.
	// Set yourRegion to the region where the bucket is located. The China (Hangzhou) region is used as an example. Set the region to cn-hangzhou. Set other regions as needed.
	clientOptions := []oss.ClientOption{oss.SetCredentialsProvider(&provider)}
	clientOptions = append(clientOptions, oss.Region("yourRegion"))
	// Set the signature version.
	clientOptions = append(clientOptions, oss.AuthVersion(oss.AuthV4))
	client, err := oss.New("yourEndpoint", "", "", clientOptions...)
	if err != nil {
		HandleError(err)
	}

	// Specify the name of the bucket where the document is stored, for example, examplebucket.
	bucketName := "examplebucket"
	bucket, err := client.Bucket(bucketName)
	if err != nil {
		HandleError(err)
	}
	// Specify the document name. If the document is not in the root directory of the bucket, you must include the full path, for example, exampledir/demo.docx.
	ossObjectName := "demo.docx"
	// Generate a signed URL and set the expiration time to 3,600s. (The maximum validity period is 32,400 seconds.)
	signedURL, err := bucket.SignURL(ossObjectName, oss.HTTPGet, 3600, oss.Process("doc/snapshot,target_jpg,source_docx,page_2"))
	if err != nil {
		HandleError(err)
	} else {
		fmt.Println(signedURL)
	}
}

Node.js

const OSS = require("ali-oss");

// Define a function to generate a signed URL.
async function generateSignatureUrl(fileName) {
  // Get the signed URL.
  const client = await new OSS({
      // Obtain access credentials from environment variables. Before running this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
      accessKeyId: process.env.OSS_ACCESS_KEY_ID,
      accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
      bucket: 'examplebucket',
      // Set yourregion to the region where the bucket is located. The China (Hangzhou) region is used as an example. Set the region to oss-cn-hangzhou.
      region: 'oss-cn-hangzhou',
      // Set secure to true to use HTTPS and prevent the browser from blocking the generated download link.
      secure: true,
      authorizationV4: true
  });

  return await client.signatureUrlV4('GET', 3600, {
      headers: {}, // Set the request headers based on the actual request that you send.
      queries: {
        "x-oss-process": "doc/snapshot,target_jpg,source_docx,page_1" // Build the document snapshot processing instruction to get a snapshot of the first page of the document.
    }
  }, fileName);
}
// Call the function and pass the file name.
generateSignatureUrl('yourFileName').then(url => {
  console.log('Generated Signature URL:', url);
}).catch(err => {
  console.error('Error generating signature URL:', err);
});

PHP

<?php
if (is_file(__DIR__ . '/../autoload.php'))  {
    require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
    require_once __DIR__ . '/../vendor/autoload.php';
}

use OSS\Credentials\EnvironmentVariableCredentialsProvider;
use OSS\OssClient;

// Obtain access credentials from environment variables. Before running this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
$provider = new EnvironmentVariableCredentialsProvider();
// Set yourEndpoint to the Endpoint for the region where the bucket is located. The China (Hangzhou) region is used as an example. Set the Endpoint to https://oss-cn-hangzhou.aliyuncs.com.
$endpoint = "yourEndpoint";
// Set yourRegion to the region where the bucket is located. The China (Hangzhou) region is used as an example. Set the region to cn-hangzhou. Set other regions as needed.
$region = "yourRegion";
// Specify the bucket name, for example, examplebucket.
$bucket= "examplebucket";
// Specify the full path of the object, for example, exampledir/demo.docx. The full path of the object cannot contain the bucket name.
$object = "exampledir/demo.docx";

$config = array(
        "provider" => $provider,
        "endpoint" => $endpoint,
        "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
        "region"=> $region
    );
    $ossClient = new OssClient($config);

// Generate a signed URL with image processing parameters. The URL is valid for 3,600 seconds and can be accessed directly in a browser.
$timeout = 3600;

$options = array(
    // Build the document snapshot processing instruction to get a snapshot of the first page of the document.
    OssClient::OSS_PROCESS => "doc/snapshot,target_jpg,source_docx,page_1");

$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "GET", $options);
print("Signed URL: \n" . $signedUrl);

Aşağıda oluşturulan imzalı URL'ye bir örnek verilmiştir:

https://examplebucket.oss-cn-hangzhou.aliyuncs.com/demo.docx?x-oss-process=doc%2Fsnapshot%2Ctarget_jpg%2Csource_docx%2Cpage_1&x-oss-date=20250225T023122Z&x-oss-expires=3600&x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-credential=LTAI********************%2F20250225%2Fcn-hangzhou%2Foss%2Faliyun_v4_request&x-oss-signature=c6620caa4dc160e5a70ee96b5bae08464edf7a41bb6d47432eda65474f68f26a

Oluşturulan URL'yi kopyalayın ve tarayıcınızın adres çubuğuna yapıştırarak belirtilen belge anlık görüntüsünü görüntüleyin.

Parametreler

Eylem: doc/snapshot

Aşağıdaki tabloda parametreler açıklanmaktadır.

Parametre

Tür

Gerekli

Açıklama

target

string

Hayır

Görüntünün hedef formatı. Geçerli değerler:

  • png (varsayılan)

  • jpg

source

string

Hayır

Kaynak belgenin dosya formatı. Varsayılan olarak nesne adının dosya uzantısı kullanılır. Geçerli değerler:

  • pdf

  • xlsx

  • xls

  • docx

  • doc

  • pptx

  • ppt

Not

Bu parametreyi belirtmezseniz ve nesnenin bir dosya uzantısı yoksa hata döndürülür.

page

int

Hayır

Belgenin sayfa numarası. Varsayılan değer, ilk sayfayı gösteren 1'dir. Maksimum değer 2000'dir.

İlgili API işlemleri

Yukarıdaki işlemler API çağrıları kullanılarak uygulanır. Programınız yüksek düzeyde özelleştirme gerektiriyorsanız doğrudan REST API istekleri gönderebilirsiniz. REST API istekleri gönderdiğinizde imzayı hesaplamak için kodu manuel olarak yazmanız gerekir. Authorization ortak istek üst bilgisinin nasıl hesaplanacağı hakkında daha fazla bilgi için İmza Sürüm 4 (önerilen) konusuna bakın.

example.docx dosyasının ilk sayfasının anlık görüntüsünü alma

İşleme yöntemi

Varsayılan işleme

Örnek

// Get a snapshot of the first page of example.docx.
GET /exmaple.docx?x-oss-process=doc/snapshot HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: SignatureValue

Word belgesi örneğinin ikinci sayfasının JPG anlık görüntüsünü alma

İşleme yöntemi

  • target: jpg

  • source: docx

  • page: 2

Örnek

// Get a JPG snapshot of the second page of the Word document example.
GET /exmaple?x-oss-process=doc/snapshot,target_jpg,source_docx,page_2 HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: SignatureValue

İzinler

Bir Alibaba Cloud hesabı varsayılan olarak tam izinlere sahiptir. Bir Alibaba Cloud hesabı altındaki bir Resource Access Management (RAM) kullanıcısı veya RAM rolü varsayılan olarak herhangi bir izne sahip değildir. Alibaba Cloud hesabı veya bir yönetici, bir RAM ilkesi veya bir paket ilkesi kullanarak izinleri vermelidir.

API

Eylem

Açıklama

GetObject

oss:GetObject

Bir nesneyi indirir.

oss:GetObjectVersion

Bir nesne indirilirken, nesne sürümünü versionId aracılığıyla belirtirseniz bu izin gereklidir.

kms:Decrypt

Bir nesne indirilirken, nesne meta verileri X-Oss-Server-Side-Encryption: KMS içeriyorsa bu izin gereklidir.


API


Eylem


Açıklama


Yok


oss:ProcessImm


OSS'te IMM'nin veri işleme yeteneklerinin kullanılmasına olanak tanır.


API


Eylem


Açıklama


CreateOfficeConversionTask


imm:CreateOfficeConversionTask


Belge dönüştürme veya anlık görüntü alma için IMM kullanma izni.

Faturalama

Belge anlık görüntüleri aşağıdaki faturalandırılabilir öğeler üzerinden ücretlendirilir. Faturalandırılabilir öğelerin fiyatlandırması hakkında daha fazla bilgi için OSS Fiyatlandırması ve Faturalandırılabilir öğeler konularına bakın:

API

Faturalandırılabilir öğe

Açıklama

GetObject

GET istekleri

Başarılı isteklerin sayısına göre istek ücretleri tahsil edilir.

İnternet üzerinden giden trafik

oss-cn-hangzhou.aliyuncs.com gibi bir genel uç nokta veya oss-accelerate.aliyuncs.com gibi bir hızlandırma uç noktası kullanarak GetObject işlemine çağrı yaparsanız, veri boyutuna göre İnternet üzerinden giden trafik ücretleri tahsil edilir.

IA nesnelerinin alınması

IA nesneleri alınırsa, alınan IA verilerinin boyutuna göre IA veri alma ücretleri tahsil edilir.

Gerçek zamanlı erişimin etkinleştirildiği bir paketteki Arşiv nesnelerinin alınması

Gerçek zamanlı erişimin etkinleştirildiği bir paketteki Arşiv nesnelerini alırsanız, alınan Arşiv nesnelerinin boyutuna göre Arşiv veri alma ücretleri tahsil edilir.

Aktarım hızlandırma ücretleri

Aktarım hızlandırmayı etkinleştirir ve paketinize erişmek için bir hızlandırma uç noktası kullanırsanız, veri boyutuna göre aktarım hızlandırma ücretleri tahsil edilir.


API


Faturalandırılabilir öğe


Açıklama


CreateOfficeConversionTask


DocumentConvert


Başarılı isteklerin sayısına göre istek ücretleri tahsil edilir.

Notlar

  • Belge anlık görüntüleri yalnızca eşzamanlı işlemeyi (x-oss-process yöntemi) destekler.

SSS

Bir belge anlık görüntüsü için kaynak belgenin maksimum boyutu nedir?

Bir belge anlık görüntüsü için kaynak belgenin maksimum boyutu 20 MB'tır.