-
服务器的地址是用的ip地址 使用sdk上传文件一直报403 VirtualHostDomainRequired
-
需求:上传到OBS的视频文件,想要获取视频第一帧做个预览图,请问使用OBS BrowserJS SDK有没有直接的方法可以获取。阿里云OSS是有直接的方法可以获取,如下图:
-
需求:上传完一段视频到OBS后,想要获取视频第一帧做个预览图,求助下华为云OBS BrowserJS SDK有没有直接的方法。阿里云OSS对象存储有直接的方发可以实现,如下图:
-
代码如下:PutObjectRequest request = new PutObjectRequest(){ BucketName = obsTongeName, ObjectKey = objectName, InputStream = file};request.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";PutObjectResponse response = client.PutObject(request);报错信息如下:Specified method is not supported.在这期间在nuget上换了不同的版本,HuaweiCloud.SDK.Core,HuaweiCloud.SDK.OBS.Core,都试过,还是报错,到底是什么原因?麻烦哪位大神帮忙看看原因?谢谢!
-
OBS SDK对OBS服务提供的REST API进行封装,以简化用户的开发工作。可以直接调用OBS SDK提供的接口函数即可使用OBS管理数据。本文以Java、Python、Go三种SDK为例,带您快速上手OBS的基础功能上传对象以下示例展示了上传本地文件localfile到examplebucket桶中,并将对象名设置为objectname。javaimport com.obs.services.ObsClient; import com.obs.services.exception.ObsException; import com.obs.services.model.PutObjectRequest; import java.io.File; public class PutObject004 { public static void main(String[] args) { // 您可以通过环境变量获取访问密钥AK/SK,也可以使用其他外部引入方式传入。如果使用硬编码可能会存在泄露风险 // 您可以登录访问管理控制台获取访问密钥AK/SK String ak = System.getenv("ACCESS_KEY_ID"); String sk = System.getenv("SECRET_ACCESS_KEY_ID"); // endpoint填写桶所在的endpoint, 此处以华北-北京四为例,其他地区请按实际情况填写 String endPoint = "https://obs.cn-north-4.myhuaweicloud.com"; // 创建ObsClient实例 // 使用永久AK/SK初始化客户端 ObsClient obsClient = new ObsClient(ak, sk,endPoint); try { // 文件上传 PutObjectRequest request = new PutObjectRequest(); // 上传文件到examplebucket桶中 request.setBucketName("examplebucket"); // 指定上传到examplebucket桶中的文件名称 request.setObjectKey("objectname"); // 指定本地待上传文件的路径 request.setFile(new File("localfile")); obsClient.putObject(request); System.out.println("putObject successfully"); } catch (ObsException e) { System.out.println("putObject failed"); // 请求失败,打印http状态码 System.out.println("HTTP Code:" + e.getResponseCode()); // 请求失败,打印服务端错误码 System.out.println("Error Code:" + e.getErrorCode()); // 请求失败,打印详细错误信息 System.out.println("Error Message:" + e.getErrorMessage()); // 请求失败,打印请求id System.out.println("Request ID:" + e.getErrorRequestId()); System.out.println("Host ID:" + e.getErrorHostId()); e.printStackTrace(); } catch (Exception e) { System.out.println("putObject failed"); // 其他异常信息打印 e.printStackTrace(); } } } Pythonimport com.obs.services.ObsClient; import com.obs.services.exception.ObsException; import com.obs.services.model.PutObjectRequest; import java.io.File; public class PutObject004 { public static void main(String[] args) { // 您可以通过环境变量获取访问密钥AK/SK,也可以使用其他外部引入方式传入。如果使用硬编码可能会存在泄露风险 // 您可以登录访问管理控制台获取访问密钥AK/SK String ak = System.getenv("ACCESS_KEY_ID"); String sk = System.getenv("SECRET_ACCESS_KEY_ID"); // endpoint填写桶所在的endpoint, 此处以华北-北京四为例,其他地区请按实际情况填写 String endPoint = "https://obs.cn-north-4.myhuaweicloud.com"; // 创建ObsClient实例 // 使用永久AK/SK初始化客户端 ObsClient obsClient = new ObsClient(ak, sk,endPoint); try { // 文件上传 PutObjectRequest request = new PutObjectRequest(); // 上传文件到examplebucket桶中 request.setBucketName("examplebucket"); // 指定上传到examplebucket桶中的文件名称 request.setObjectKey("objectname"); // 指定本地待上传文件的路径 request.setFile(new File("localfile")); obsClient.putObject(request); System.out.println("putObject successfully"); } catch (ObsException e) { System.out.println("putObject failed"); // 请求失败,打印http状态码 System.out.println("HTTP Code:" + e.getResponseCode()); // 请求失败,打印服务端错误码 System.out.println("Error Code:" + e.getErrorCode()); // 请求失败,打印详细错误信息 System.out.println("Error Message:" + e.getErrorMessage()); // 请求失败,打印请求id System.out.println("Request ID:" + e.getErrorRequestId()); System.out.println("Host ID:" + e.getErrorHostId()); e.printStackTrace(); } catch (Exception e) { System.out.println("putObject failed"); // 其他异常信息打印 e.printStackTrace(); } } } Gopackage main import ( "fmt" "os" obs "github.com/huaweicloud/huaweicloud-sdk-go-obs/obs" ) func main() { //推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入,如果使用硬编码可能会存在泄露风险。 //您可以登录访问管理控制台获取访问密钥AK/SK ak := os.Getenv("AccessKeyID") sk := os.Getenv("SecretAccessKey") // endpoint填写Bucket对应的Endpoint, 这里以华北-北京四为例,其他地区请按实际情况填写。 endPoint := "https://obs.cn-north-4.myhuaweicloud.com" // 创建obsClient实例 obsClient, err := obs.New(ak, sk, endPoint) if err != nil { fmt.Printf("Create obsClient error, errMsg: %s", err.Error()) } input := &obs.PutFileInput{} // 指定存储桶名称 input.Bucket = "examplebucket" // 指定上传对象,此处以 objectname 为例。 input.Key = "objectname" // 指定本地文件,此处以localfile为例 input.SourceFile = "localfile" // 文件上传 output, err := obsClient.PutFile(input) if err == nil { fmt.Printf("Put file(%s) under the bucket(%s) successful!\n", input.Key, input.Bucket) fmt.Printf("StorageClass:%s, ETag:%s\n", output.StorageClass, output.ETag) return } fmt.Printf("Put file(%s) under the bucket(%s) fail!\n", input.Key, input.Bucket) if obsError, ok := err.(obs.ObsError); ok { fmt.Println("An ObsError was found, which means your request sent to OBS was rejected with an error response.") fmt.Println(obsError.Error()) } else { fmt.Println("An Exception was found, which means the client encountered an internal problem when attempting to communicate with OBS, for example, the client was unable to access the network.") fmt.Println(err) } } 下载对象本示例用于下载examplebucket桶中的objectname对象。javaimport com.obs.services.ObsClient; import com.obs.services.exception.ObsException; import com.obs.services.model.ObsObject; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class GetObject001 { public static void main(String[] args) { // 您可以通过环境变量获取访问密钥AK/SK,也可以使用其他外部引入方式传入。如果使用硬编码可能会存在泄露风险。 // 您可以登录访问管理控制台获取访问密钥AK/SK String ak = System.getenv("ACCESS_KEY_ID"); String sk = System.getenv("SECRET_ACCESS_KEY_ID"); // endpoint填写桶所在的endpoint, 此处以华北-北京四为例,其他地区请按实际情况填写。查看桶所在的endpoint请参见:https://support.huaweicloud.com/usermanual-obs/obs_03_0312.html。 String endPoint = "https://obs.cn-north-4.myhuaweicloud.com"; // 创建ObsClient实例 // 使用永久AK/SK初始化客户端 ObsClient obsClient = new ObsClient(ak, sk,endPoint); try { // 流式下载 ObsObject obsObject = obsClient.getObject("examplebucket", "objectname"); // 读取对象内容 System.out.println("Object content:"); InputStream input = obsObject.getObjectContent(); byte[] b = new byte[1024]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); int len; while ((len = input.read(b)) != -1) { bos.write(b, 0, len); } System.out.println("getObjectContent successfully"); System.out.println(new String(bos.toByteArray())); bos.close(); input.close(); } catch (ObsException e) { System.out.println("getObjectContent failed"); // 请求失败,打印http状态码 System.out.println("HTTP Code:" + e.getResponseCode()); // 请求失败,打印服务端错误码 System.out.println("Error Code:" + e.getErrorCode()); // 请求失败,打印详细错误信息 System.out.println("Error Message:" + e.getErrorMessage()); // 请求失败,打印请求id System.out.println("Request ID:" + e.getErrorRequestId()); System.out.println("Host ID:" + e.getErrorHostId()); e.printStackTrace(); } catch (Exception e) { System.out.println("getObjectContent failed"); // 其他异常信息打印 e.printStackTrace(); } } } Pythonfrom obs import GetObjectRequest from obs import ObsClient import os import traceback # 推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入。如果使用硬编码可能会存在泄露风险 # 您可以登录访问管理控制台获取访问密钥AK/SK ak = os.getenv("AccessKeyID") sk = os.getenv("SecretAccessKey") # server填写Bucket对应的Endpoint, 这里以华北-北京四为例,其他地区请按实际情况填写。 server = "https://obs.cn-north-4.myhuaweicloud.com" # 创建obsClient实例 obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server) try: # 下载对象的附加请求参数 getObjectRequest = GetObjectRequest() # 获取对象时重写响应中的Content-Type头。 getObjectRequest.content_type = 'text/plain' bucketName="examplebucket" objectKey="objectname" #流式下载 resp = obsClient.getObject(bucketName=bucketName,objectKey=objectKey, getObjectRequest=getObjectRequest, loadStreamInMemory=False) # 返回码为2xx时,接口调用成功,否则接口调用失败 if resp.status < 300: print('Get Object Succeeded') print('requestId:', resp.requestId) # 读取对象内容 while True: chunk = resp.body.response.read(65536) if not chunk: break print(chunk) resp.body.response.close() else: print('Get Object Failed') print('requestId:', resp.requestId) print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage) except: print('Get Object Failed') print(traceback.format_exc()) Gopackage main import ( "fmt" "os" obs "github.com/huaweicloud/huaweicloud-sdk-go-obs/obs" ) func main() { //推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入,如果使用硬编码可能会存在泄露风险。 //您可以登录访问管理控制台获取访问密钥AK/SK ak := os.Getenv("AccessKeyID") sk := os.Getenv("SecretAccessKey") // endpoint填写Bucket对应的Endpoint, 这里以华北-北京四为例,其他地区请按实际情况填写。 endPoint := "https://obs.cn-north-4.myhuaweicloud.com" // 创建obsClient实例 obsClient, err := obs.New(ak, sk, endPoint) if err != nil { fmt.Printf("Create obsClient error, errMsg: %s", err.Error()) } input := &obs.GetObjectInput{} // 指定存储桶名称 input.Bucket = "examplebucket" // 指定下载对象,此处以 objectname 为例。 input.Key = "objectname" // 流式下载对象 output, err := obsClient.GetObject(input) if err == nil { // output.Body 在使用完毕后必须关闭,否则会造成连接泄漏。 defer output.Body.Close() fmt.Printf("Get object(%s) under the bucket(%s) successful!\n", input.Key, input.Bucket) fmt.Printf("StorageClass:%s, ETag:%s, ContentType:%s, ContentLength:%d, LastModified:%s\n", output.StorageClass, output.ETag, output.ContentType, output.ContentLength, output.LastModified) // 读取对象内容 p := make([]byte, 1024) var readErr error var readCount int for { readCount, readErr = output.Body.Read(p) if readCount > 0 { fmt.Printf("%s", p[:readCount]) } if readErr != nil { break } } return } fmt.Printf("List objects under the bucket(%s) fail!\n", input.Bucket) if obsError, ok := err.(obs.ObsError); ok { fmt.Println("An ObsError was found, which means your request sent to OBS was rejected with an error response.") fmt.Println(obsError.Error()) } else { fmt.Println("An Exception was found, which means the client encountered an internal problem when attempting to communicate with OBS, for example, the client was unable to access the network.") fmt.Println(err) } }
-
在let result = await this.obs.putObject(params);这段代码短暂卡住后被catch,日志显示"code":2300006,"message":"Couldn't resolve host name"。obs = new ObsClient({AccessKeyId: Const.CONST_AccessKeyId,SecretAccessKey: Const.CONST_SecretAccessKey,Server: Const.TEST_BUCKET_Server,PathStyle: true});
-
技术干货 数据库常见的死锁cid:link_0 MySQL中操作同一条记录的死锁问题及解决cid:link_1 数据库走索引但查询仍很慢所造成的一些原因cid:link_2 mysql中常见的减少回表增加查询性能的方法cid:link_11 InnoDB的一次更新事务的背后cid:link_12 MySQL的行级锁小知识点cid:link_13 MySQL 中常见的当前读和快照读cid:link_3 华为云 GaussDB 管理平台(TPoPS)页面实时告警推送方法总结cid:link_4 quartz用GaussDB的getJobDetail方法报错“For input string: "\x"常见解决方法cid:link_14 开发者空间的ubuntu系统安装dockercid:link_5 GAUSSDB根据实际业务负载动态优化数据分片策略cid:link_15 GaussDB分布式环境下保证分布式事务ACID属性主要方式cid:link_6 使用MySQL全文索引(Full-text Index)笔记cid:link_7 实现MySQL多主复制的几种常见方法cid:link_8 MySQL的查询缓存笔记分享cid:link_9 MySQL数据库常见的实现数据备份与恢复cid:link_16 MySQL主从复制cid:link_17 MySQL 处理外键约束cid:link_18 如何设计高效的数据库索引策略cid:link_10
-
通过createSignedUrlSync创建的请求临时url请求结果:访问URL:应用代码:通过生成的此url可以进行文件的上传,但是生成的的url访问不可以。
-
【技术干货汇总】华为云主机Ubuntu环境下使用obsutil上传文件到OBS cid:link_2华为云主机自动同步数据文件到OBS cid:link_3【技术答疑】问题1问: Web客户端大量用户通过浏览器上传下载,目前使用OBS做存储。 上传下载严重阻碍其他业务应用访问。 OBS是否提供到这种传输方式:给Web客户端授权后,从OBS直接down到客户本地,不再麻烦web服务器?还是我选择的方式有问题。 我这种需求是不是必须用CDN才能解决?答: cid:link_5 可以web直传obs; cid:link_0 下载对象可以参考browserjs临时授权访问。问题2问: 我用obs的流失上传 为什么在ObsClient obsClient = new ObsClient(ACCESS_KEY_ID, SECRET_ACCESS_KEY_ID,ObS_ENDPOINT);的时候 会出现Exception in thread "main" java.lang.NoSuchMethodError kotlin.collections.ArraysKt.copyInto([B[BIII)[B这个问题呢答: 参考这个文档:cid:link_4 依赖缺失和依赖冲突是 Java 开发中的常见问题,在集成 SDK 的过程中也会遇到,在应用编译和运行时报错 ClassNotFoundException 与 NoClassDefFoundError 时可怀疑是否是依赖问题而导致,针对不同情况参照下述步骤进行排查和解决。问题3问:obs上传对象报错 com.amazonaws.SdkClientException: Unable to execute HTTP request: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target https上传到obs报这个错,是因为我服务端没有安装obs的https证书吗答: 服务端校验证书失败; sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification 错误原因: 用户未传入有效的证书路径,公有云已经统一购买证书,hcso证书需要客户单独购买。 解决方案: 方式一: 设置不校验证书:validateCertificate 设置为false,详见:cid:link_1 方式二: 改为http协议访问,在endpoint参数前加 http://协议头。 方式三: 购买ca证书,并设置路径,详见:cid:link_1
-
场景:Web客户端大量用户通过浏览器上传下载,目前使用OBS做存储。问题:上传下载严重阻碍其他业务应用访问。OBS是否提供到这种传输方式:给Web客户端授权后,从OBS直接down到客户本地,不再麻烦web服务器?还是我选择的方式有问题。我这种需求是不是必须用CDN才能解决?谢谢~
-
D:\Downloads\supersonic-master>mvn install [INFO] Scanning for projects... [INFO] Artifact org.springframework.boot:spring-boot-dependencies:pom:3.2.4 is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from [aliyunmaven (https://maven.aliyun.com/repository/public, default, releases)] [INFO] Artifact org.springframework.boot:spring-boot-dependencies:pom:3.2.4 is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from [aliyunmaven (https://maven.aliyun.com/repository/public, default, releases)] Downloading from aliyunmaven: https://maven.aliyun.com/repository/public/org/springframework/boot/spring-boot-dependencies/3.2.4/spring-boot-dependencies-3.2.4.pom [ERROR] [ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM for org.springframework.boot:spring-boot-starter-parent:3.2.4: The following artifacts could not be resolved: org.springframework.boot:spring-boot-dependencies:pom:3.2.4 (present, but unavailable): Could not transfer artifact org.springframework.boot:spring-boot-dependencies:pom:3.2.4 from/to aliyunmaven (https://maven.aliyun.com/repository/public): Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty @ org.springframework.boot:spring-boot-starter-parent:3.2.4, D:\Documents\.m2\repository\org\springframework\boot\spring-boot-starter-parent\3.2.4\spring-boot-starter-parent-3.2.4.pom, line 4, column 11 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project com.tencent.supersonic:supersonic:${revision} (D:\Downloads\supersonic-master\pom.xml) has 1 error [ERROR] Non-resolvable parent POM for org.springframework.boot:spring-boot-starter-parent:3.2.4: The following artifacts could not be resolved: org.springframework.boot:spring-boot-dependencies:pom:3.2.4 (present, but unavailable): Could not transfer artifact org.springframework.boot:spring-boot-dependencies:pom:3.2.4 from/to aliyunmaven (https://maven.aliyun.com/repository/public): Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty @ org.springframework.boot:spring-boot-starter-parent:3.2.4, D:\Documents\.m2\repository\org\springframework\boot\spring-boot-starter-parent\3.2.4\spring-boot-starter-parent-3.2.4.pom, line 4, column 11 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException从错误日志可以看出,Maven 构建错误信息来看,主要问题在于 Maven 无法从配置的阿里云 Maven 仓库(aliyunmaven)下载所需的 spring-boot-dependencies POM 文件。错误提示中出现了 java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty,这通常表明 Java 的 SSL/TLS 配置存在问题,特别是与信任库(trust store)有关。因此,我们选择通过以下两种方式忽略证书校验命令行忽略SSL校验mvn -X clean install -Dmaven.resolver.transport=wagon -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=trueIDEA忽略SSL校验Build,Execution.Deployment --> Build Tools --> Maven --> Importing : VM options for importer 增加1中忽略ssl校验的实例; Build,Execution.Deployment --> Build Tools --> Maven --> Runner: VM Options 增加1中忽略ssl校验的实例; maven Runner 是在执行goals时自动添加的。 maven Importing 时idea引入依赖时的操作,此时并没有执行goals。
-
[问题求助] 我用obs的流失上传 为什么在ObsClient obsClient = new ObsClient(ACCESS_KEY_ID, SECRET_ACCESS_KEY_ID,ObS_ENDPOINT);的时候我用obs的流失上传 为什么在ObsClient obsClient = new ObsClient(ACCESS_KEY_ID, SECRET_ACCESS_KEY_ID,ObS_ENDPOINT);的时候 会出现Exception in thread "main" java.lang.NoSuchMethodError kotlin.collections.ArraysKt.copyInto([B[BIII)[B这个问题呢
-
从OBS下载文件夹时,使用ModelArts Session鉴权,但对应区域无法选择西南-贵阳一,产生:ValueError: Unrecognized region name of cn-southwest-2查看源码发现确实不支持,那如何完成session鉴权呢:SUPPORTED_REGION = ['cn-north-1', 'cn-north-2', 'cn-north-4', 'cn-north-5', 'cn-north-7', 'cn-northeast-1', 'cn-north-9', 'cn-east-2', 'cn-south-1', 'ap-southeast-1', 'cn-east-3', 'ap-southeast-3', 'cn-hangzhou-1', 'eu-west-0']
-
com.amazonaws.SdkClientException: Unable to execute HTTP request: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target https上传到obs报这个错,是因为我服务端没有安装obs的https证书吗
-
使用点播VOD这个服务在哪里设置自动执行呢?比如我上传到OBS中的视频,该服务就自动进行视频封面设置,然后在存储到OBS中,或者直接覆盖源文件
推荐直播
-
一键部署DeepSeek大模型,解锁AI智能未来
2025/02/17 周一 16:00-17:00
华为云讲师团
云上体验DeepSeek大模型,用AI加速行业应用场景重塑,满足企业级业务需求
回顾中 -
DeepSeek华为云全栈解决方案
2025/02/18 周二 16:30-17:30
Young-华为云公有云解决方案专家
如何让大模型发挥更大能量助力业务?本期课程以真实案例展开,带您深入探索如何构建更完整的AI解决方案。
即将直播
热门标签