Upload Method | Upload Domain | Credentials | Supported Operations |
Bucket Internal Preset Domain | [BucketId].vodsrc-internal.[Region].eovod.com | AccessKeys | Upload to specified bucket |
1234567890ap-guangzhoubucketid1bucketid1.vodsrc-internal.ap-guangzhou.eovod.comAccessKeyId and SecretAccessKey from the key management of the professional version application. For detailed steps, refer to the Key Management documentationnslookup. If resolved IPs resemble 10.*.*.*, 100.*.*.*, or 169.254.*.*, intranet access is available.// Package main// This example is implemented based on AWS SDK for Go v2 service/s3 v1.72.3.// For AWS SDK for Go v2 service/s3 v1.73.0 and later versions, S3's default integrity protection must be disabled.// For more details, refer to: https://github.com/aws/aws-sdk-go-v2/discussions/2960package mainimport ("context""errors""fmt""log""net/url""os""github.com/aws/aws-sdk-go-v2/aws""github.com/aws/aws-sdk-go-v2/credentials""github.com/aws/aws-sdk-go-v2/feature/s3/manager""github.com/aws/aws-sdk-go-v2/service/s3"smep "github.com/aws/smithy-go/endpoints""github.com/aws/smithy-go/logging")// Custom endpoint resolvertype customEndpointResolverV2 struct{}func (r *customEndpointResolverV2) ResolveEndpoint(ctx context.Context,params s3.EndpointParameters) (smep.Endpoint, error) {if params.Bucket == nil || params.Region == nil {return smep.Endpoint{}, errors.New("invalid endpoint param")}return smep.Endpoint{URI: url.URL{Scheme: "https",Host: fmt.Sprintf("%s.vodsrc-internal.ap-guangzhou.eovod.com", *params.Bucket),},}, nil}func main() {// Initialize S3 clients3cli := s3.New(s3.Options{Credentials: credentials.NewStaticCredentialsProvider("AccessKeyId", // Replace with your AccessKeyId"SecretAccessKey", // Replace with your SecretAccessKey""), // SessionToken not needed for AccessKeysEndpointResolverV2: new(customEndpointResolverV2), // Custom endpointUsePathStyle: false, // Disable path styleLogger: logging.NewStandardLogger(os.Stdout), // Log to stdoutClientLogMode: aws.LogRequest | aws.LogResponse, // Log headersRegion: "auto", // Must be "auto"})// Open local filefile, err := os.Open("demo.mp4") // Local file pathif err != nil {log.Fatalf("failed to open file: %v", err)return}defer file.Close()// Upload file to S3uploader := manager.NewUploader(s3cli, func(u *manager.Uploader) {u.PartSize = 10 * 1024 * 1024 // Set chunk size to 10MBu.Concurrency = 5 // Set concurrent chunks})result, err := uploader.Upload(context.TODO(), &s3.PutObjectInput{Bucket: aws.String("bucketid1"), // Bucket ID in VOD ProfessionalKey: aws.String("upload/demo.mp4"), // File path in bucketBody: file,})if err != nil {log.Fatalf("failed to upload file: %v", err)return}log.Printf("etag: %s", *result.ETag) // Get uploaded file's ETag}
// This example is implemented based on AWS SDK for Java v2 service/s3 v2.31.35.// For AWS SDK for Java 2.30.0 and later versions, S3's default integrity protection must be disabled.// For more details, refer to: https://github.com/aws/aws-sdk-java-v2/issues/5801import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;import software.amazon.awssdk.regions.Region;import software.amazon.awssdk.services.s3.S3AsyncClient;import software.amazon.awssdk.services.s3.S3Configuration;import software.amazon.awssdk.transfer.s3.S3TransferManager;import software.amazon.awssdk.transfer.s3.model.UploadFileRequest;import software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener;import software.amazon.awssdk.core.checksums.RequestChecksumCalculation;import software.amazon.awssdk.core.checksums.ResponseChecksumValidation;import java.io.File;import java.net.URI;import java.util.concurrent.CompletableFuture;public class Main {public static void main(String[] args) {S3AsyncClient s3AsyncClient = null;S3TransferManager transferManager = null;try {// VOD Professional AccessKeysAwsBasicCredentials credentials = AwsBasicCredentials.create("AccessKeyId", // Your AccessKeyId"SecretAccessKey" // Your SecretAccessKey);String region = "ap-guangzhou"; // Bucket regionString bucketId = "bucketid1"; // Bucket IDString filePath = "demo.mp4"; // Local file pathString key = "upload/demo.mp4"; // File path in bucketString endpointUrl = String.format("https://vodsrc-internal.%s.eovod.com", region);// Build S3 async clients3AsyncClient = S3AsyncClient.builder().credentialsProvider(StaticCredentialsProvider.create(credentials)).endpointOverride(URI.create(endpointUrl)).region(Region.of("auto")) // Must be "auto".httpClient(NettyNioAsyncHttpClient.builder().build()).serviceConfiguration(S3Configuration.builder().pathStyleAccessEnabled(false) // Disable path style.build()).requestChecksumCalculation(RequestChecksumCalculation.WHEN_REQUIRED).responseChecksumValidation(ResponseChecksumValidation.WHEN_REQUIRED).build();// Create transfer managertransferManager = S3TransferManager.builder().s3Client(s3AsyncClient).build();File fileToUpload = new File(filePath);// Create upload requestUploadFileRequest uploadRequest = UploadFileRequest.builder().putObjectRequest(builder -> builder.bucket(bucketId).key(key)).addTransferListener(LoggingTransferListener.create()).source(fileToUpload).build();// Execute uploadCompletableFuture<Void> future = transferManager.uploadFile(uploadRequest).completionFuture().thenAccept(response -> {System.out.println("Upload successful! ETag: " + response.response().eTag());});future.join();System.out.println("Upload task completed");} catch (Exception e) {System.err.println("Upload failed: " + e.getMessage());e.printStackTrace();} finally {// Cleanup resourcestry {if (transferManager != null) transferManager.close();if (s3AsyncClient != null) s3AsyncClient.close();System.out.println("Resources released");} catch (Exception e) {System.err.println("Error closing resources: " + e.getMessage());}}}}
// This example is implemented based on AWS SDK for C++ v1.11.560.// For AWS SDK for C++ v1.11.486 and later versions, S3's default integrity protection must be disabled.// For more details, refer to: https://github.com/aws/aws-sdk-cpp/issues/3253#include <aws/core/Aws.h>#include <aws/core/auth/AWSCredentials.h>#include <aws/core/client/ClientConfiguration.h>#include <aws/s3/S3Client.h>#include <aws/transfer/TransferManager.h>#include <iostream>int main(){// Initialize AWS SDKAws::SDKOptions options;options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Info;Aws::InitAPI(options);{// Configurationconst Aws::String accessKeyId = "AccessKeyId"; // Your AccessKeyIdconst Aws::String secretAccessKey = "SecretAccessKey"; // Your SecretAccessKeyconst Aws::String region = "ap-guangzhou"; // Bucket regionconst Aws::String bucketId = "bucketid1"; // Bucket IDconst Aws::String keyName = "upload/demo.mp4"; // File path in bucketconst Aws::String filePath = "demo.mp4"; // Local file path// Configure clientAws::Client::ClientConfiguration clientConfig;clientConfig.region = "auto"; // Must be "auto"clientConfig.scheme = Aws::Http::Scheme::HTTPS; // Use HTTPSclientConfig.enableEndpointDiscovery = false; // Disable endpoint discoveryclientConfig.verifySSL = true; // Enable SSL verificationclientConfig.endpointOverride = "vodsrc-internal." + region + ".eovod.com";clientConfig.checksumConfig.requestChecksumCalculation = Aws::Client::RequestChecksumCalculation::WHEN_REQUIRED;clientConfig.checksumConfig.responseChecksumValidation = Aws::Client::ResponseChecksumValidation::WHEN_REQUIRED;// Set credentialsAws::Auth::AWSCredentials credentials(accessKeyId, secretAccessKey);// Create S3 clientauto s3Client = Aws::MakeShared<Aws::S3::S3Client>("S3Client",credentials,clientConfig,Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, // Disable payload signingtrue // Use virtual addressing);// Create executorauto executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("executor", 10);// Configure TransferManagerAws::Transfer::TransferManagerConfiguration transferConfig(executor.get());transferConfig.s3Client = s3Client;transferConfig.bufferSize = 10 * 1024 * 1024; // 10MB chunk size// Create TransferManagerauto transferManager = Aws::Transfer::TransferManager::Create(transferConfig);std::cout << "Starting upload: " << filePath << " to " << bucketId << "/" << keyName << std::endl;// Execute uploadauto uploadHandle = transferManager->UploadFile(filePath, // Local file pathbucketId, // Bucket IDkeyName, // Object key"application/octet-stream", // Content typeAws::Map<Aws::String, Aws::String>() // Metadata);// Wait for completionuploadHandle->WaitUntilFinished();// Check statusif (uploadHandle->GetStatus() == Aws::Transfer::TransferStatus::COMPLETED){std::cout << "Upload successful!" << std::endl;}else{auto lastError = uploadHandle->GetLastError();std::cerr << "Upload failed: " << lastError.GetMessage() << std::endl;}}// Cleanup SDKAws::ShutdownAPI(options);return 0;}
#!/usr/bin/env python3# -*- coding: utf-8 -*-import boto3from botocore.config import Configfrom botocore.exceptions import ClientError# ConstantsREGION = "ap-guangzhou" # Bucket regionBUCKET_ID = "bucketid1" # Bucket IDFILE_PATH = "demo.mp4" # Local file pathOBJECT_KEY = "upload/demo.mp4" # File path in bucket# Create S3 clients3_client = boto3.client("s3",aws_access_key_id="AccessKeyId", # Your AccessKeyIdaws_secret_access_key="SecretAccessKey", # Your SecretAccessKeyendpoint_url=f"https://vodsrc-internal.{REGION}.eovod.com", # Bucket endpointconfig=Config(s3={"addressing_style": "virtual"}, # Use virtual hosted-stylerequest_checksum_calculation="when_required", # Disable default integrity protectionresponse_checksum_validation="when_required",),)try:# Upload fileresponse = s3_client.upload_file(Bucket=BUCKET_ID, # Bucket IDKey=OBJECT_KEY, # File path in bucketFilename=FILE_PATH, # Local file path)print(response)except ClientError as e:print(f"Error: {e}")
피드백