Tüm Ürünler
Search
Belge Merkezi

Object Storage Service:Statik web sitesi barındırma (yansıtma tabanlı kaynak sunucudan çekme) (OSS SDK for Java 1.0)

Son Güncelleme:Oct 01, 2026

Bir paketi statik web sitesi barındırma için yapılandırabilir ve yansıtma tabanlı kaynak sunucudan çekme için yönlendirme kuralları (RoutingRule) belirtebilirsiniz. Statik web sitesi barındırmayı etkinleştirdiğinizde, web sitesine yapılan istekler pakete yapılan isteklere eşdeğerdir. Ayrıca belirtilen bir dizin sayfasına ve hata sayfasına otomatik yönlendirmeler de yapılandırabilirsiniz. Yansıtma tabanlı kaynak sunucudan çekme kuralları, verilerinizi Object Storage Service (OSS) hizmetine sorunsuz bir şekilde geçirmenize yardımcı olur.

Notlar

  • Bu konuda Çin (Hangzhou) bölgesinin genel uç noktası kullanılır. Aynı bölgedeki diğer Alibaba Cloud hizmetlerinden OSS hizmetine erişmek için dahili uç nokta kullanın. Desteklenen bölgeler ve uç noktalar hakkında ayrıntılı bilgi için bkz. Bölgeler ve uç noktalar.

  • Bu konuda erişim kimlik bilgileri ortam değişkenlerinden alınır. Daha fazla bilgi için bkz. Erişim Kimlik Bilgilerini Yapılandırma.

  • Bu konu, bir OSS uç noktası kullanarak bir OSSClient örneği oluşturmayı gösterir. Özel etki alanı kullanma veya Security Token Service (STS) kimlik bilgileriyle kimlik doğrulama gibi alternatif yapılandırmalar için bkz. İstemci yapılandırması.

  • Statik web sitesi barındırma veya yansıtma tabanlı kaynak sunucudan çekmeyi yapılandırmak için oss:PutBucketWebsite iznine sahip olmanız gerekir. Statik web sitesi barındırma veya yansıtma tabanlı kaynak sunucudan çekme yapılandırmasını almak için oss:GetBucketWebsite iznine sahip olmanız gerekir. Statik web sitesi barındırma veya yansıtma tabanlı kaynak sunucudan çekme yapılandırmasını silmek için oss:DeleteBucketWebsite iznine sahip olmanız gerekir. Daha fazla bilgi için bkz. RAM kullanıcılarına özel erişim ilkeleri atama.

Statik web sitesi barındırma

  • Statik web sitesi barındırmayı yapılandırma

    Aşağıdaki kod, statik web sitesi barındırmanın nasıl yapılandırılacağını gösterir:

    import com.aliyun.oss.*;
    import com.aliyun.oss.common.auth.*;
    import com.aliyun.oss.common.comm.SignVersion;
    import com.aliyun.oss.model.SetBucketWebsiteRequest;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            // The China (Hangzhou) Endpoint is used as an example. Specify the actual Endpoint.
            String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
            // Obtain access credentials from environment variables. Before you run 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 region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, 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 its resources.
            ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
            clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);        
            OSS ossClient = OSSClientBuilder.create()
            .endpoint(endpoint)
            .credentialsProvider(credentialsProvider)
            .clientConfiguration(clientBuilderConfiguration)
            .region(region)               
            .build();
    
            try {
                // Specify the bucket name.
                SetBucketWebsiteRequest request = new SetBucketWebsiteRequest(bucketName);
                // Set the default homepage for static website hosting.
                request.setIndexDocument("index.html");
                // Set the default 404 page for static website hosting.
                request.setErrorDocument("error.html");
                ossClient.setBucketWebsite(request);
            } 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();
                }
            }
        }
    }
  • Statik web sitesi barındırma yapılandırmasını görüntüleme

    Aşağıdaki kod, statik web sitesi barındırma yapılandırmasının nasıl görüntüleneceğini gösterir:

    import com.aliyun.oss.*;
    import com.aliyun.oss.common.auth.*;
    import com.aliyun.oss.common.comm.SignVersion;
    import com.aliyun.oss.model.BucketWebsiteResult;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            // The China (Hangzhou) Endpoint is used as an example. Specify the actual Endpoint.
            String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
            // Obtain access credentials from environment variables. Before you run 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 region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, 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 its resources.
            ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
            clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);        
            OSS ossClient = OSSClientBuilder.create()
            .endpoint(endpoint)
            .credentialsProvider(credentialsProvider)
            .clientConfiguration(clientBuilderConfiguration)
            .region(region)               
            .build();
    
            try {
                // Specify the bucket name.
                BucketWebsiteResult result = ossClient.getBucketWebsite(bucketName);
                // View the default homepage and default 404 page of the static website hosting configuration.
                System.out.println(result.getIndexDocument());
                System.out.println(result.getErrorDocument());
            } 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();
                }
            }
        }
    }
  • Statik web sitesi barındırma yapılandırmasını silme

    Aşağıdaki kod, statik web sitesi barındırma yapılandırmasının nasıl silineceğini gösterir:

    import com.aliyun.oss.*;
    import com.aliyun.oss.common.auth.*;
    import com.aliyun.oss.common.comm.SignVersion;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            // The China (Hangzhou) Endpoint is used as an example. Specify the actual Endpoint.
            String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
            // Obtain access credentials from environment variables. Before you run 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 region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, 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 its resources.
            ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
            clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);        
            OSS ossClient = OSSClientBuilder.create()
            .endpoint(endpoint)
            .credentialsProvider(credentialsProvider)
            .clientConfiguration(clientBuilderConfiguration)
            .region(region)               
            .build();
    
            try {
                // Specify the bucket name.
                ossClient.deleteBucketWebsite(bucketName);
            } 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();
                }
            }
        }
    }

Yansıtma tabanlı kaynak sunucudan çekme

Yansıtma tabanlı kaynak sunucudan çekme, öncelikli olarak verilerin OSS hizmetine sorunsuz bir şekilde geçirilmesi için kullanılır. Örneğin, hizmetiniz kendi kaynak sunucunuzda veya başka bir cloud ürününde çalışıyor olabilir. Hizmeti iş geliştirme amacıyla OSS hizmetine geçirmek istiyorsanız, geçiş sırasında hizmetin kesintisiz çalışmasını sağlamalısınız. Geçiş sürecinde, OSS hizmetine henüz taşınmamış verileri almak için yansıtma tabanlı kaynak sunucudan çekme kurallarını kullanabilirsiniz. Bu sayede hizmetinizin beklendiği gibi çalışmasını garanti edersiniz.

  • Yansıtma tabanlı kaynak sunucudan çekmeyi yapılandırma

    Örneğin, bir istekçi hedef pakette bulunmayan bir dosyaya erişmeye çalıştığında, nesne dosyasını kaynak sunucudan almak için kaynak sunucuya yönlendirme koşullarını ve bir kaynak URL'sini belirtebilirsiniz. Örneğin, Çin (Hangzhou) bölgesinde examplebucket adlı bir paketiniz bulunmaktadır. Bir istekçi, paketin kök dizinindeki examplefolder klasöründe bulunmayan bir dosyaya erişmeye çalışırsa, istekçinin https://www.example.com/ sitesinin examplefolder klasöründen nesne dosyasını alabilmesini isteyebilirsiniz.

    Aşağıdaki kod, önceki senaryo için yansıtma tabanlı kaynak sunucudan çekme kuralının nasıl yapılandırılacağını gösterir:

    import com.aliyun.oss.*;
    import com.aliyun.oss.common.auth.*;
    import com.aliyun.oss.common.comm.SignVersion;
    import com.aliyun.oss.model.RoutingRule;
    import com.aliyun.oss.model.SetBucketWebsiteRequest;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            // The China (Hangzhou) Endpoint is used as an example. Specify the actual Endpoint.
            String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
            // Obtain access credentials from environment variables. Before you run 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 region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, 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 its resources.
            ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
            clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);        
            OSS ossClient = OSSClientBuilder.create()
            .endpoint(endpoint)
            .credentialsProvider(credentialsProvider)
            .clientConfiguration(clientBuilderConfiguration)
            .region(region)               
            .build();
    
            try {
                SetBucketWebsiteRequest request = new SetBucketWebsiteRequest(bucketName);
                // The behavior when an object that does not exist and whose name does not end with a forward slash (/) is accessed. This takes effect after a default homepage is set.
                //request.setSubDirType(null);
                // Specifies whether to redirect to the default homepage of a subdirectory when the subdirectory is accessed.
                //request.setSupportSubDir(false);
    
                List<RoutingRule> routingRules = new ArrayList<RoutingRule>();
    
                RoutingRule rule = new RoutingRule();
                rule.setNumber(1);
                // Only objects with this prefix can match this rule.
                rule.getCondition().setKeyPrefixEquals("examplebucket");
                // The rule is matched only if an HTTP status code of 404 is returned for a request to the specified object.
                rule.getCondition().setHttpErrorCodeReturnedEquals(404);
                // Specify the redirect type.
                rule.getRedirect().setRedirectType(RoutingRule.RedirectType.Mirror);
                // Specify the origin URL for mirroring-based back-to-origin. For example, https://www.example.com/.
                rule.getRedirect().setMirrorURL("<yourMirrorURL>");
                //rule.getRedirect().setMirrorRole("AliyunOSSMirrorDefaultRole");
                // Specifies whether to include request parameters when a redirection or mirroring-based back-to-origin rule is executed.
                rule.getRedirect().setPassQueryString(true);
                // This parameter has the same function as PassQueryString but has a higher priority. This parameter takes effect only when RedirectType is set to Mirror.
                rule.getRedirect().setMirrorPassQueryString(true);
                // Specify the status code to return for the redirection. This parameter takes effect only when RedirectType is set to External or AliCDN.
                //rule.getRedirect().setHttpRedirectCode(302);
                // Specify the domain name for the redirection. The domain name must be compliant with domain name specifications.
                //rule.getRedirect().setHostName("oss.aliyuncs.com");
                // Specify the protocol for the redirection. This parameter takes effect only when RedirectType is set to External or AliCDN.
                //rule.getRedirect().setProtocol(RoutingRule.Protocol.Https);
                // During redirection, the object name is replaced with the value of ReplaceKeyWith. ReplaceKeyWith supports variables.
                //rule.getRedirect().setReplaceKeyWith("${key}.jpg");
                // If this parameter is set to true, the prefix of the object name is replaced with the value of ReplaceKeyPrefixWith.
                rule.getRedirect().setEnableReplacePrefix(true);
                // During redirection, the prefix of the object name is replaced with this value.
                rule.getRedirect().setReplaceKeyPrefixWith("examplebucket");
                // Specifies whether to check the MD5 hash of the back-to-origin body. This parameter takes effect only when RedirectType is set to Mirror.
                rule.getRedirect().setMirrorCheckMd5(true);
    
                RoutingRule.MirrorHeaders mirrorHeaders = new RoutingRule.MirrorHeaders();
                // Specifies whether to pass through headers other than the following to the origin server. This parameter takes effect only when RedirectType is set to Mirror.
                mirrorHeaders.setPassAll(false);
                List passes = new ArrayList<String>();
                passes.add("cache-control");
                // Pass through the specified headers to the origin server. This parameter takes effect only when RedirectType is set to Mirror.
                mirrorHeaders.setPass(passes);
                List removes = new ArrayList<String>();
                removes.add("content-type");
                // Prohibit the pass-through of specified headers to the origin server. This parameter takes effect only when RedirectType is set to Mirror.
                mirrorHeaders.setRemove(removes);
                List sets = new ArrayList<Map<String, String>>();
                Map header1 = new HashMap<String, String>();
                header1.put("Key", "key1");
                header1.put("Value", "value1");
                Map header2 = new HashMap<String, String>();
                header2.put("Key", "key2");
                header2.put("Value", "value2");
                sets.add(header1);
                sets.add(header2);
                // Set the headers to pass to the origin server. These headers are set for back-to-origin requests, regardless of whether they are included in the original request.
                mirrorHeaders.setSet(sets);
                // Specify the headers to include in back-to-origin requests. This parameter takes effect only when RedirectType is set to Mirror.
                rule.getRedirect().setMirrorHeaders(mirrorHeaders);
    
                routingRules.add(rule);
                request.setRoutingRules(routingRules);
                ossClient.setBucketWebsite(request);
            } 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();
                }
            }
        }
    }
  • Yansıtma tabanlı kaynak sunucudan çekme yapılandırmasını alma

    Aşağıdaki kod, yansıtma tabanlı kaynak sunucudan çekme yapılandırmasının nasıl alınacağını gösterir:

    import com.aliyun.oss.*;
    import com.aliyun.oss.common.auth.*;
    import com.aliyun.oss.common.comm.SignVersion;
    import com.aliyun.oss.model.BucketWebsiteResult;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            // The China (Hangzhou) Endpoint is used as an example. Specify the actual Endpoint.
            String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
            // Obtain access credentials from environment variables. Before you run 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 region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, 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 its resources.
            ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
            clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);        
            OSS ossClient = OSSClientBuilder.create()
            .endpoint(endpoint)
            .credentialsProvider(credentialsProvider)
            .clientConfiguration(clientBuilderConfiguration)
            .region(region)               
            .build();
    
            try {
                BucketWebsiteResult result = ossClient.getBucketWebsite(bucketName);
                result.getSubDirType();
                // Get the ordinal number of the redirection or mirroring-based back-to-origin rule that is matched and executed.
                System.out.println(result.getRoutingRules().get(0).getNumber());
                // Get the prefix that the rule matches.
                System.out.println(result.getRoutingRules().get(0).getCondition().getKeyPrefixEquals());
                // Get the HTTP status code.
                System.out.println(result.getRoutingRules().get(0).getCondition().getHttpErrorCodeReturnedEquals());
                // Get the suffix that the rule matches.
                System.out.println(result.getRoutingRules().get(0).getCondition().getKeySuffixEquals());
                // Get the redirect type.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getRedirectType());
                // Get the carried request parameters.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getMirrorPassQueryString());
                // Get the origin URL for mirroring-based back-to-origin.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getMirrorURL());
                // Get the status code returned for the redirection.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getHttpRedirectCode());
                // Get the specified headers to pass through.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getMirrorHeaders().getPass().get(0));
                // Get the specified headers that are prohibited from being passed through.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getMirrorHeaders().getRemove().get(0));
                // Get the protocol for the redirection.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getProtocol());
                // Get the domain name for the redirection.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getHostName());
                // Get the value to replace the prefix of the object name during redirection. If the prefix is empty, this string is inserted at the beginning of the object name.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getReplaceKeyPrefixWith());
                // Get the replacement value for the object name specified by ReplaceKeyWith during redirection. ReplaceKeyWith supports variables.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getReplaceKeyWith());
                // Get the status code returned for the redirection.
                System.out.println(result.getRoutingRules().get(0).getRedirect().getHttpRedirectCode());
            } 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();
                }
            }
        }
    }
  • Yansıtma tabanlı kaynak sunucudan çekme yapılandırmasını silme

    Aşağıdaki kod, yansıtma tabanlı kaynak sunucudan çekme yapılandırmasının nasıl silineceğini gösterir:

    import com.aliyun.oss.*;
    import com.aliyun.oss.common.auth.*;
    import com.aliyun.oss.common.comm.SignVersion;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            // The China (Hangzhou) Endpoint is used as an example. Specify the actual Endpoint.
            String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
            // Obtain access credentials from environment variables. Before you run 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 region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, 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 its resources.
            ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
            clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);        
            OSS ossClient = OSSClientBuilder.create()
            .endpoint(endpoint)
            .credentialsProvider(credentialsProvider)
            .clientConfiguration(clientBuilderConfiguration)
            .region(region)               
            .build();
    
            try {
                // Specify the bucket name.
                ossClient.deleteBucketWebsite(bucketName);
            } 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();
                }
            }
        }
    }

İlgili konular

  • Statik web sitesi barındırma ve yansıtma tabanlı kaynak sunucudan çekme için tam örnek kodu görmek üzere GitHub örneğine bakın.

  • Statik web sitesi barındırma veya yansıtma tabanlı kaynak sunucudan çekmeyi yapılandırmak için kullanılan API işlemi hakkında daha fazla bilgi için bkz. PutBucketWebsite.

  • Statik web sitesi barındırma veya yansıtma tabanlı kaynak sunucudan çekme yapılandırmasını almak için kullanılan API işlemi hakkında daha fazla bilgi için bkz. GetBucketWebsite.

  • Statik web sitesi barındırma veya yansıtma tabanlı kaynak sunucudan çekme yapılandırmasını silmek için kullanılan API işlemi hakkında daha fazla bilgi için bkz. DeleteBucketWebsite.