aliyun / aliyun-oss-react-native Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
'http://verzqli.oss-cn-beijing.aliyuncs.com';
比如这样一个链接 我看你的例子
const endPoint = 'oss-cn-beijing.aliyuncs.com';
const familyserver = "http://verzqli";
AliyunOSS.initWithServerSTS(familyserver,endPoint, configuration)
这样写
3blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:84148 Error: Can't get a federation token
[ErrorMessage]: Can't get a federation token
at createErrorFromErrorData (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2043)
at blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:1995
at MessageQueue.__invokeCallback (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2437)
at blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2182
at MessageQueue.__guardSafe (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2350)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/2fd25a6f-097f-4117-a812-6a306372306b:2181)
at debuggerWorker.js:70
报这个错,请问什么原因?
类似于android的 String url = oss.presignConstrainedObjectURL("", "", 30 * 60);
接口。貌似还没写好??
我剪切图片后上传时报错 No such file or directory,发现原因是 getFilePathFromURI 方法中没有正确获取缓存中的图片地址.
原图片地址
file:///storage/emulated/0/Android/data/com.awesomeapp/cache/1554800192263.jpg
通过 getFilePathFromURI 获取的图片地址
file:///storage/emulated/0/1554800192263.jpg // No such file or directory
应该直接把 file:// 去掉就能使用了.
public static String getFilePathFromURI(Context context, Uri contentUri) {
Log.d("oldfeel", "getFilePathFromURI: " + contentUri);
//copy file and send new file path
if(contentUri.toString().contains(context.getApplicationContext().getPackageName())){
return contentUri.toString().substring(6);
}
String fileName = getFileName(contentUri);
if (!TextUtils.isEmpty(fileName)) {
File copyFile = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + fileName);
FileUtils.copy(context, contentUri, copyFile);
return copyFile.getAbsolutePath();
}
return null;
}
`if([options objectForKey:@"delimiter"]) {
getBucket.delimiter = [options objectForKey:@"delimiter"];
}
if([options objectForKey:@"marker"]) {
getBucket.marker = [options objectForKey:@"marker"];
}
if([options objectForKey:@"prefix"]) {
getBucket.prefix = [options objectForKey:@"prefix"];
}
if([options objectForKey:@"maxkeys"]) {
getBucket.maxKeys = [[options objectForKey:@"maxkeys"] intValue];
}`
这一块是修改后的代码,望更新!
FAILURE: Build failed with an exception.
com.android.ide.common.process.ProcessException: Failed to execute aapt
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s
as the title says, i suffers a more than 5 secs uploading time cost even i set quality to 0.5 or even less, which leads the image blurred. I dont think its network problem, cus everything is all right on iOS and can be reproduced every time on Android.
国外用户经常进度不动,有的时候可以上传,有的时候不能
用户在马来西亚,
bucket在上海
const downloadProgress = p => console.log(p.currentSize / p.totalSize);
AliyuOSS.addEventListener('uploadProgress', downloadProgress);
不走downloadProgress回调
xocde: 10.2.1
RN: 0.57.5
完全照搬手动示例,确认无任何步骤遗漏,均无果
这是什么问题?
貌似只提供了下载图片的方法?
server是一个返回AccessKeyId,AccessKeySecret等的接口地址么。看文档有点不太明白。
环境是: android 虚拟机;
"aliyun-oss-react-native": "^1.0.0-alpha.5",
"react-native": "0.55.4",
"react-native-image-picker": "^0.26.10",
采用 initWithPlainTextAccessKey 方式 初始化的 AliyunOSS 调用 asyncUpload API上传, 在IOS下一切正常, android 下 出现异常,异常信息 [Info] 07-17 14:25:19.988 4873 5287 I ReactNativeJS: { [Error: Can't get a federation token 07-17 14:25:19.988 4873 5287 I ReactNativeJS: [ErrorMessage]: Can't get a federation token] framesToPop: 1, code: 'EUNSPECIFIED' }
我增加了
AliyunOSS.addEventListener('uploadProgress', (p) => {
console.log('here?');
});
好像这个方法都没有进来
参数格式如下
[Info] 07-17 15:31:38.498 4231 5445 I ReactNativeJS: 'bucketName', 'mxb-bucket'
07-17 15:31:38.499 4231 5445 I ReactNativeJS: 'objectKey', '9b00b88bb0e565ef153181269835840383image-0459516f-6e3d-4891-84c9-387c4e89a350.jpg'
07-17 15:31:38.499 4231 5445 I ReactNativeJS: 'url', 'file:///storage/emulated/0/Android/data/com.app_merchant_tao_mian_xi/files/Pictures/image-0459516f-6e3d-4891-84c9-387c4e89a350.jpg'
asyncUpload上传会卡死js线程一会,请问是什么情况,目前测的是android
Replace react-native link
to react-native link aliyun-oss-react-native
, otherwise this command will gen exist duplicate link infomation.
我看到 asyncListObjects (bucketName,prefix='') 这个接口,但是不能使用分隔符?
在鉴权的时候,鉴权服务器需要客户端token(sessionId)来判定这个人是谁,所以需要在设置 AliyunOSS.initWithServerSTS 的时候来提供客户端Token。是否能在未来进行支持?
看文档说上传图片,需要设置contentType为image/jpeg,但是我找不到设置的地方.
configuration:
const AliOSS = {
endpoint: 'oss-cn-hongkong.aliyuncs.com',
config: {
maxRetryCount: 3,
timeoutIntervalForRequest: 30,
timeoutIntervalForResource: 24 * 60 * 60
},
securityToken: '', // get from server
accessKey: '',
secretKey: '',
};
...
AliyunOSS.enableDevMode();
AliyunOSS.initWithSecurityToken(r.securityToken, r.accessKeyId, r.accessKeySecret, AliOSS.endpoint, AliOSS.config)
AliyunOSS.addEventListener('uploadProgress', (p) => {
let per = parseInt(p.currentSize / p.totalSize * 10);
if (per !== logCount) {
logCount = per;
JLLog('uploadProgress ' + per);
}
});
use like this :
AliyunOSS.asyncUpload('bwoil-file', 'jonglim/hand-test' + rendom++, source[0].uri).then((res) => {
JLLog({ AliyunOSS: res })
}).catch((error) => {
JLLog({ AliyunOSS: error })
})
log
07-13 17:18:14.924 7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 1
07-13 17:18:14.932 7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 2
...
07-13 17:18:14.966 7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 9
07-13 17:18:14.970 7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 10
07-13 17:18:15.019 7028 12904 I ReactNativeJS: >> NewPostScreen.js << {"AliyunOSS":{"framesToPop":1,"code":"EUNSPECIFIED"}}
Anyone know what's wrong with this?
注意:使用STS授权的时候传入的服务器地址最好是ip或者域名,不然无法运行的。
/**
* Initialize the OSS Client
* Mode: ImplementedSigner
*/
initWithImplementedSigner(signature, accessKey, endPoint, configuration = conf) {
RNAliyunOSS.initWithImplementedSigner(signature, accessKey, endPoint, configuration);
},
但是 RNAAliyunOssModule.java
只有 initWithSigner方法,没有 initWithImplementedSigner
react-native init Ex
cd ./Ex
npm i aliyun-oss-react-native
react-native link aliyun-oss-react-native
// add the tdb, and two framework in Link Frameworks and Librarys
// add the AliYunOssSDK.framework in Frameworks
but can's run
ld: framework not found AliyunOSSiOS
clang: error: linker command failed with exit code 1 (use -v to see invocation)
源码
if (cursor == null) sourceFile = selectedVideoUri.getPath();
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
sourceFile = cursor.getString(column_index);
应该改为
if (cursor == null) {
sourceFile = selectedVideoUri.getPath();
}
else{
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
sourceFile = cursor.getString(column_index);
}
否则会进入catch逻辑中创建一个临时文件,而这个临时文件并不会在上传后删掉,麻烦修正下
谢谢
如题
如题,使用asyncUpload上传图片,貌似没有看到如何同时上传多张图片,求教
系统:
android
配置:
1,
include ':aliyun-oss-react-native'
project(':aliyun-oss-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/aliyun-oss-react-native/android')
2,
//OSS
implementation project(':aliyun-oss-react-native')
3,
addPackage(new RNAliyunOssPackage());
compileSdkVersion 27
defaultConfig {
applicationId "com.qcec.valhalla"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
ndk {
abiFilters 'armeabi', 'x86',"armeabi-v7a"
}
}
错误:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:524)
at com.android.build.gradle.tasks.MergeManifests.doFullTaskAction(MergeManifests.java:143)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more
项目中的ReactNative框架,没有使用Cocoapods导入。
然后配置aliyun-oss-react-native的时候,选择了“no CocoaPods”。
出现了几个问题, 我本地修改了,才能编译通过。
问题1: 导入RNAliyunOSS.xcodeproj,项目中只包含了RNAliyunOSS.h和RNAliyunOSS.m两个文件。
修改:把其他几个RNAliyunOSS+XXX.h和.m文件引入项目文件中
问题2:#import <RNAliyunOSS.h>导致编译失败
修改:由于直接在项目中引用RNAliyunOSS工程,所以<>的import方式会失败。修改成#import "RNAliyunOSS.h"
问题3:RNAliyunOSS+AUTH.m中, 无法找到OSSAuthCredentialProvider
RCT_EXPORT_METHOD(initWithServerSTS:(NSString *)server endPoint:(NSString *)endPoint configuration:(NSDictionary *)configuration){
//直接访问鉴权服务器(推荐,token过期后可以自动更新)
id<OSSCredentialProvider> credential = [[OSSAuthCredentialProvider alloc] initWithAuthServerUrl:server];
[self initConfiguration: configuration];
self.client = [[OSSClient alloc] initWithEndpoint:endPoint credentialProvider:credential clientConfiguration:self.clientConfiguration];
}
修改:由于我们的RN项目中不需要使用initWithServerSTS,所以我先暂时把里面的代码给注释掉了。
希望能够帮助到其他小伙伴。
https://helpcdn.aliyun.com/document_detail/63262.html
要上传的文件切分成Part之后,
文件顺序是通过上传过程中指定的partNumber来确定的,实际执行中并没有顺序要求,
因此可以实现并发上传。具体的并发个数并不是越多速度越快,
要结合用户自身的网络情况和设备负载综合考虑。
Right now multipart upload for android and ios are implemented by uploading each part synchronously.
If one part fails, there is no retry, the entire upload fails.
This implementation does not receive many of the benefits of using multipart upload. Uploading in parallel should make the upload faster.
Do you know where I can find a parallel implementation multipart upload for android and ios?
编译ios,xcode中编译通过后,在iPhone x模拟器中调用initMultipartUpload接口没反应,也不报错,android正常
我使用的是expo,安装aliyun-oss-react-native之后提示:
[ts]
Could not find a declaration file for module 'aliyun-oss-react-native'. 'h:/projectNew/client/node_modules/aliyun-oss-react-native/index.js' implicitly has an 'any' type.
Try npm install @types/aliyun-oss-react-native
if it exists or add a new declaration (.d.ts) file containing declare module 'aliyun-oss-react-native';
[7016]
module "h:/projectNew/client/node_modules/aliyun-oss-react-native/index"
音频文件,图片等上传成功之后请求头在OSS中查看请求头都是application/octet-stream,怎么设置上传请求头等格式?
Could not find auto-linked framework 'AliyunOSSiOS'
clone 项目后执行,npm install
后,在xcode中启动,无法找到 -lRCTBlob
这个依赖库,并且RCTBlob.xcodeproj 也是缺失的
ld: library not found for -lRCTBlob
clang: error: linker command failed with exit code 1 (use -v to see invocation)
确实AliyunOSSiOS.a的链接,需要手动修改,否则会报链接错误
上面是我上传成功之后的图片地址,?号之前的objectKey我可以理解,但是问号之后的Expires自动加上去的吗???如何可以去除掉,我是使用的initWithSecurityToken授权的方式,也请你写一下configuration这个参数的文档说明,谢谢
什么时候出flutter 版
Android 包名 com.reactlibrary
与 react-native-syan-image-picker 包名冲突。
建议采用三级包名!!
请问会提供URL签名的方法吗?
asyncUpload 上传成功,返回的数据类型,怎么拿到url
返回结果--- <OSSTask: 0x6000022dc1c0; completed = YES; cancelled = NO; faulted = NO; result = OSSResult<0x6000023a3500> : {httpResponseCode: 200, requestId: 5BD96FE20C51712121F47F85, httpResponseHeaderFields: {
Connection = "keep-alive";
"Content-Length" = 0;
"Content-MD5" = "xBqgoHuQvuTNX0u+SFPMSA==";
Date = "Wed, 31 Oct 2018 09:03:31 GMT";
Etag = ""C41AA0A07B90BEE4CD5F4BBE4853CC48"";
Server = AliyunOSS;
"x-oss-hash-crc64ecma" = 3024406496928251140;
"x-oss-request-id" = 5BD96FE20C51712121F47F85;
"x-oss-server-time" = 184;
}, local_crc64ecma: (null)}>
1.中文readme文档中的
AliyunOSS.initWithSecurityToken(/*local auth server*/, endPoint, configuration);
应该是
AliyunOSS.initWithServerSTS("/***http://ip:port/****/",endPoint, configuration)
2.使用
AliyunOSS.asyncUpload(bucketname, objectKey, filepath).then((res) => {
// 这里并不能判断是否上传成功
// 还需要根据返回的res判断 httpResponseCode是否为200
// 当为200状态码的时候才是上传成功
}).catch()
OSS.initWithPlainTextAccessKey(accessKey, secretKey, endPoint);
OSS.asyncListObjects(bucket, {
delimiter: '/'
}).then(res => {
console.log(res);
// Portal.remove(toastKey);
}).catch(err => {
debugger
});
then、catch都未返回内容
要不是为了吃饭...
<!-- log的查看可以通过React Native自带的调试工具也可通过XCode Log控制台进行查看 -->
你看看你们写的这什么玩意儿...比你们阿里飞燕系统的文档还草,人家团队好歹还写个不准确的或者不能用的。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.