package com.itheima;
import cn.leancloud.AVFile;
import cn.leancloud.AVLogger;
import cn.leancloud.core.AVOSCloud;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import org.jetbrains.annotations.NotNull;
public class test {
public static void main(String[] args) {
AVOSCloud.setLogLevel(AVLogger.Level.DEBUG);
AVOSCloud.initialize("eeryryerfgfgryeryrgfaaaaaaaaaaaaaaaaaz", "aaaaaaaaaaaaaaaaaaaaaaaaa", "upload.qiniup.com");
AVFile file = new AVFile("resume.jpg", "LeanCloud".getBytes());
file.saveInBackground().subscribe(new Observer<AVFile>() {
public void onSubscribe(Disposable disposable) {}
public void onNext(AVFile file) {
System.out.println("文件保存完成。objectId:" + file.getObjectId());
}
public void onError(@NotNull Throwable throwable) {
// 保存失败,可能是文件无法被读取,或者上传过程中出现问题
System.out.println(throwable.getMessage());
}
public void onComplete() {}
});
}
}
四月 18, 2021 8:45:53 上午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: [Thread-1] obtained writeLock for file: d:\IdeaProjects\hello_world\.\file\7cdbdcc2b1777c14d9da30e98c1c9a35
四月 18, 2021 8:45:53 上午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: [Thread-1] release writeLock for file: d:\IdeaProjects\hello_world\.\file\7cdbdcc2b1777c14d9da30e98c1c9a35
四月 18, 2021 8:45:53 上午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: [Thread-1] createToken params: {"name":"resume.jpg","metaData":{"_name":"resume.jpg","size":9,"_checksum":"7cdbdcc2b1777c14d9da30e98c1c9a35"},"mime_type":"image/jpeg","__type":"File"}, {"className":"_File","serverData":{}}
四月 18, 2021 8:45:54 上午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: [Thread-1] Request: curl -X POST
-H Accept: application/json
-H Content-Type: application/json
-H User-Agent: LeanCloud-Java-SDK/7.2.3
-H X-LC-Id: eeryryerfgfgryeryrgfaaaaaaaaaaaaaaaaaz
-H X-LC-Prod: 1
-H X-LC-Session: {your_session}
-H X-LC-Sign: {your_sign}
-d '{"name":"resume.jpg","metaData":{"_name":"resume.jpg","size":9,"_checksum":"7cdbdcc2b1777c14d9da30e98c1c9a35"},"mime_type":"image/jpeg","__type":"File"}'
https://upload.qiniup.com/1.1/fileTokens
四月 18, 2021 8:45:54 上午 cn.leancloud.logging.SimpleLogger internalWriteLog
详细: [Thread-1] Response: 400
Server: openresty/1.17.8.2
Date: Sun, 18 Apr 2021 00:45:55 GMT
Content-Type: application/json
Content-Length: 84
Connection: keep-alive
Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size
Access-Control-Allow-Methods: OPTIONS, HEAD, POST
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Log, X-Reqid
Access-Control-Max-Age: 2592000
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Reqid: C94AAAAKI8o3zXYW
X-Svr: UP
X-Log: X-Log
{"error":"invalid multipart format: request Content-Type isn't multipart/form-data"}
invalid multipart format: request Content-Type isn't multipart/form-data
Process finished with exit code 0
maven一干二净:
<dependencies>
<dependency>
<groupId>cn.leancloud</groupId>
<artifactId>storage-core</artifactId>
<version>7.2.3</version>
</dependency>
</dependencies>
基本按照开发指南来的,key随便改都到不了验证的那一步,难道输入的地址不是这个?
我用REST API 服务器地址提示:
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
百度了下好像要什么安全证书,但都是很老的帖子了,感觉希望不大就没试。
反正就很奇怪,是我指南里漏看了上什么吗?