tencent cloud

masukan

Configuring Preflight Requests for Cross-Origin Access

Terakhir diperbarui:2024-02-02 14:36:36

    Overview

    This document provides an overview of APIs and SDK sample codes related to preflight request for cross-origin access.
    API
    Operation
    Description
    Sending a preflight request for cross-origin access
    Sends a preflight request to check whether a real cross-origin access request can be sent

    Sending a Preflight Request for Cross-origin Access

    API description

    This API is used to send a preflight request for the cross-origin access configuration.

    Sample code

    try
    {
    string bucket = "examplebucket-1250000000"; // Bucket in the format: BucketName-APPID
    string key = "exampleobject"; // Object key
    string origin = "http://cloud.tencent.com";
    string accessMthod = "PUT";
    OptionObjectRequest request = new OptionObjectRequest(bucket, key, origin, accessMthod);
    // Set the validity period of the signature
    request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
    // Execute the request
    OptionObjectResult result = cosXml.OptionObject(request);
    // Request succeeded
    Console.WriteLine(result.GetResultInfo());
    }
    catch (COSXML.CosException.CosClientException clientEx)
    {
    // Request failed
    Console.WriteLine("CosClientException: " + clientEx);
    }
    catch (COSXML.CosException.CosServerException serverEx)
    {
    // Request failed
    Console.WriteLine("CosServerException: " + serverEx.GetInfo());
    }
    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