Open mercierj opened 1 year ago
@mercierj One reason could be that he doesn't have all the permission granted because upload using input stream creates a temp file before uploading to S3, so I would start by confirming that. If the issue is still not fixed, then we would need logs to investigate further.
Also, a suggestion based on the code snippet you pasted, you can use uploadFile api directly if you are trying to upload a file. This will prevent redundant operation of converting file to inputstream and then again inputstream to temp file.
Hi @sdhuka, thanks for your fast reply.
The user has authorized : CAMERA, RECORD_AUDIO, ACCESS_MEDIA_LOCATION, READ_MEDIA_VIDEOS, READ_MEDIA_IMAGES
I used the uploadFile before but I switched to inputStream trying to solve his bug, with same result unfortunately. No error except uploading through amplify when I manually copy a file from inputStream content provider for video trimming. I know ... I will try to get some logs 😅
@mercierj In that case, yes, please add logs and we will investigate further.
Hi @sdhuka I've set up an alert which leads me to the cause : "the difference between the request time and the current time is too large". The phone my client is using has no simcard, I have deduced that it was related to his system clock. It seems like System. currentTimeMillis can be wrong on some phones without simcard. When he disabled the automatic timezone setting and he set manually any timezone it started to work. Maybe using another way to get timestamp than currentTimeMillis would fix this kind of problems ?
Hi, I have the same problem and one way to reproduce it is by maintaining the AS internal database inspector. When it is held open at 100% charge it is aborted and the status changes to failed.
Something went wrong with your AWS S3 Storage upload file operation
@mercierj Thanks for finding the root cause, could you please paste the stacktrace here so we can look into fixing the issue?
I don't have access to the device or stacktrace, I had to debug remotely through some alert dialogs unfortunately.
Same issue got on file upload. After first failed attempt all next attempts fail with error:
SinglePartUploadWorker failed with exception: java.io.IOException: kotlinx.coroutines.JobCancellationException: Parent job is Completed; job=JobImpl{Completed}@6458966
at aws.smithy.kotlin.runtime.http.engine.okhttp.StreamingRequestBody.writeTo(StreamingRequestBody.kt:46)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:64)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.android.tools.profiler.agent.okhttp.OkHttp3Interceptor.intercept(OkHttp3Interceptor.java:57)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.android.tools.appinspection.network.okhttp.OkHttp3Interceptor.intercept(OkHttp3Interceptor.kt:52)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:65)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:205)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:537)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Caused by: kotlinx.coroutines.JobCancellationException: Parent job is Completed; job=JobImpl{Completed}@6458966
Hi @sdhuka I've set up an alert which leads me to the cause : "the difference between the request time and the current time is too large". The phone my client is using has no simcard, I have deduced that it was related to his system clock. It seems like System. currentTimeMillis can be wrong on some phones without simcard. When he disabled the automatic timezone setting and he set manually any timezone it started to work. Maybe using another way to get timestamp than currentTimeMillis would fix this kind of problems ?
I would like to second this problem, I have been getting this issue for a handful of uploads.
I think it's related to System.currentTimeMillis used in the library. https://stackoverflow.com/questions/45509101/system-currenttimemillis-returns-incorrect-timestamp-on-huawei Using Instant.toEpochMilli() instead of System.currentTimeMillis() in the base code might fix the problem no ?
I encountered the same problem. When a test mobile phone opens the VPN, it enters the program, then disconnects the VPN, and then uploads the file again. This error occurs. Even so, the error occurs again with the VPN. Restart the app after recovery.
fun upload( fileKey: String, fileStream: InputStream, onFailed: (Exception) -> Unit, onSuccess: (String) -> Unit ) { val option = StorageUploadInputStreamOptions.builder() .accessLevel(StorageAccessLevel.PUBLIC) .build()
Amplify.Storage.uploadInputStream(fileKey, fileStream, option,
{ result ->
MSGLog.log("uploadS3 success:${result.key}")
},
{ e ->
e.printStackTrace()
}
)
}
Before opening, please confirm:
Language and Async Model
Kotlin - Coroutines
Amplify Categories
Storage
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
Hi ! I'm using the coroutines koltin sdk for uploading files (images/ video). Everything is working well on any devices tested on my side (physical & simulated), from any Android version (API 26 -> 33). My client located in French Polynesia, with a samsung A13 (Android 13), using wifi with good internet connection is not able to upload any file. He keeps getting "Something went wrong with your AWS S3 Storage upload input stream operation" right away. The content is either from his gallery or by capture intents. I'm using the same amplifyconfiguration.json on iOS & Android, and there is no bug on iOS side. Since I'm not able to reproduce this on my side, I don't have any logs for now. I would consider remote debuging but my client is not really available to help me with this task. Do you have any hint on what could cause this bug ? maybe a location related issue ? He is not using any simcard (but neither do I on my test devices). I don't have access to the backend unfortunately.
Thanks for your help, Regards
Reproduction steps (if applicable)
No response
Code Snippet
Log output
amplifyconfiguration.json
GraphQL Schema
Additional information and screenshots