缺少 api 键 android Cloudinary 上传错误
Missing api key android Cloudinary upload error
AndroidManifest.xml
<meta-data
android:name="CLOUDINARY_URL"
android:value="${cloudinaryUrl}" />
在我上传文件的 activity 中,我初始化了 MediaManager
MediaManager.init(this);
并且我已经使用它的 uri 上传了文件:
val requestId = MediaManager.get().upload(uri).callback(object : UploadCallback {
override fun onStart(requestId: String) {
// your code here
}
override fun onProgress(requestId: String, bytes: Long, totalBytes: Long) {
// example code starts here
val progress = bytes.toDouble() / totalBytes
// post progress to app UI (e.g. progress bar, notification)
// example code ends here
}
override fun onSuccess(requestId: String, resultData: Map<*, *>) {
// your code here
}
override fun onError(requestId: String, error: ErrorInfo) {
// your code here
}
override fun onReschedule(requestId: String, error: ErrorInfo) {
// your code here
}
}).dispatch()
问题是我遇到错误 'Missing api key'
。未签名的上传是否需要 api 密钥?
通过查看文档 here。在示例中,您需要传递 SignatureProvider
示例代码:
Map config = new HashMap();
config.put("cloud_name", "myCloudName");
MediaManager.init(this, new SignatureProvider(){
@Override
public Signature provideSignature(Map options) {
// replace the following with a function that calls your backend signature generation endpoint
SignResult res = signUpload(options); // example name of a function that implements a synchronous HTTPS call
return new Signature(res.getSignature(), res.getApiKey(), res.getTimestamp());
}
@Override
public String getName() {
return "SampleSignatureProvider"; // for logging purposes
}
}, config);
To enable signed uploads you need to update your call to the
MediaManager's init method with the name of an instance of your class
(init(Context, SignatureProvider, Map)). Your class will be
implemented whenever an upload must be signed.
查看 SignatureProvider 界面
编辑
对于未签名的上传,您没有提到 .unsigned("sample_preset")
和 MediaManager.get().upload(uri)
。欲了解更多信息 see here
AndroidManifest.xml
<meta-data
android:name="CLOUDINARY_URL"
android:value="${cloudinaryUrl}" />
在我上传文件的 activity 中,我初始化了 MediaManager
MediaManager.init(this);
并且我已经使用它的 uri 上传了文件:
val requestId = MediaManager.get().upload(uri).callback(object : UploadCallback {
override fun onStart(requestId: String) {
// your code here
}
override fun onProgress(requestId: String, bytes: Long, totalBytes: Long) {
// example code starts here
val progress = bytes.toDouble() / totalBytes
// post progress to app UI (e.g. progress bar, notification)
// example code ends here
}
override fun onSuccess(requestId: String, resultData: Map<*, *>) {
// your code here
}
override fun onError(requestId: String, error: ErrorInfo) {
// your code here
}
override fun onReschedule(requestId: String, error: ErrorInfo) {
// your code here
}
}).dispatch()
问题是我遇到错误 'Missing api key'
。未签名的上传是否需要 api 密钥?
通过查看文档 here。在示例中,您需要传递 SignatureProvider
示例代码:
Map config = new HashMap();
config.put("cloud_name", "myCloudName");
MediaManager.init(this, new SignatureProvider(){
@Override
public Signature provideSignature(Map options) {
// replace the following with a function that calls your backend signature generation endpoint
SignResult res = signUpload(options); // example name of a function that implements a synchronous HTTPS call
return new Signature(res.getSignature(), res.getApiKey(), res.getTimestamp());
}
@Override
public String getName() {
return "SampleSignatureProvider"; // for logging purposes
}
}, config);
To enable signed uploads you need to update your call to the MediaManager's init method with the name of an instance of your class (init(Context, SignatureProvider, Map)). Your class will be implemented whenever an upload must be signed.
查看 SignatureProvider 界面
编辑
对于未签名的上传,您没有提到 .unsigned("sample_preset")
和 MediaManager.get().upload(uri)
。欲了解更多信息 see here