tencent cloud

masukan

Object Access URL

Terakhir diperbarui:2024-01-23 17:15:08

    Overview

    This document provides code samples to obtain an object URL.
    Note:
    This API is used to query the URL to access an object. It does not verify whether the object exists or not.
    The URL generated using this API cannot be used to access private-read objects. For such objects, you can generate a URL by referring to Generating Pre-Signed URLs.

    SDK API References

    For parameters and method description of all APIs in the SDK, please see SDK API Reference.

    Obtaining Object URLs

    Sample code 1. Obtaining an object access URL

    Objective-C
    QCloudGetPresignedURLRequest* getPresignedURLRequest = [[QCloudGetPresignedURLRequest alloc] init];
    
    // Generate an unsigned URL
    getPresignedURLRequest.isUseSignature = false:
    
    // Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
    getPresignedURLRequest.bucket = @"examplebucket-1250000000";
    
    // Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "video/xxx/movie.mp4"
    getPresignedURLRequest.object = @"exampleobject";
    
    [getPresignedURLRequest setFinishBlock:^(QCloudGetPresignedURLResult * _Nonnull result,
    NSError * _Nonnull error) {
    // Pre-Signed URL
    NSString* presignedURL = result.presienedURL;
    
    }];
    
    [[QCloudCOSXMLService defaultCOSXML] getPresignedURL:getPresignedURLRequest];
    Note:
    For the complete sample, go to GitHub.
    Swift
    let getPresign = QCloudGetPresignedURLRequest.init();
    
    // Generate an unsigned URL
    getPresign.isUseSignature = false;
    // Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
    getPresign.bucket = "examplebucket-1250000000" ;
    
    // Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "video/xxx/movie.mp4"
    getPresign.object = "exampleobject";
    
    getPresign.setFinish { (result, error) in
    if let result = result {
    let url = result.presienedURL
    } else {
    print(error!);
    }
    }
    QCloudCOSXMLService.defaultCOSXML().getPresignedURL(getPresign);
    Note:
    For the complete sample, go to GitHub.
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24