Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: "The requested resource could not be found" on video upload And does not return video info on success #19

Open
imsujan276 opened this issue Jul 17, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@imsujan276
Copy link

imsujan276 commented Jul 17, 2024

Version

1.2.3

Environment that reproduces the issue

Device: Pixel 5 mobile and emulator
Flutter version: 3.22.1

Is it reproducible in the example application?

Not tested

Reproduction steps

  • select a video
  • upload it using "ApiVideoUploader.uploadPart" or "ApiVideoUploader.upload"
  • script used to upload video
 ApiVideoUploader.setApiKey('API_KEY');
  ApiVideoUploader.setChunkSize(1024 * 1024 * 5); // 5mb chunk size
   final session = ApiVideoUploader.createProgressiveUploadSession(
        _generateRandomString(10),
      );
      final video = await session.uploadPart(
        videoPath,
        onProgress: (progress) {
          EasyLoad.progress(
            percentage: progress,
            message: 'Uploading ${(progress * 100).toStringAsFixed(2)}%',
          );
        },
      );
 print(video)

Expected result

  1. There should not be any error like that
  2. On success, it should return video info

Actual result

  1. on success, you see an error message in console "Error: PlatformException(java.lang.UnsupportedOperationException, Not Found: The requested resource could not be found., java.lang.UnsupportedOperationException: Not Found: The requested resource could not be found."
  2. I do not get the uploaded video info

Additional context

No response

Relevant logs output

Full error message:
[log] LOG => _uplaodVideoToAPiVideo() Error: PlatformException(java.lang.UnsupportedOperationException, Not Found: The requested resource could not be found., java.lang.UnsupportedOperationException: Not Found: The requested resource could not be found.
at video.api.flutter.uploader.UploaderModuleImpl$uploadPartAndObserve$4.invoke(UploaderModuleImpl.kt:346)
at video.api.flutter.uploader.UploaderModuleImpl$uploadPartAndObserve$4.invoke(UploaderModuleImpl.kt:333)
at video.api.flutter.uploader.utils.LiveDataExtensionsKt$observeTillItFinishes$4.onChanged(LiveDataExtensions.kt:36)
at video.api.flutter.uploader.utils.LiveDataExtensionsKt$observeTillItFinishes$4.onChanged(LiveDataExtensions.kt:20)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
, null)
@imsujan276 imsujan276 added the bug Something isn't working label Jul 17, 2024
@ThibaultBee
Copy link
Member

Hi,

Your upload token might not be valid. Could you double check it?
See https://docs.api.video/reference/resource-not-found for reference.

@ThibaultBee
Copy link
Member

From what I understand from your stack trace, your are trying to upload by part and not with uploadWithUploadToken. Could you provide the real code sample?

@imsujan276
Copy link
Author

Hi,

Your upload token might not be valid. Could you double check it? See https://docs.api.video/reference/resource-not-found for reference.

It is valid. I copied it from api.video dashboard and the selected video does gets uploaded to the videos section in api.video. It just does not return any response and shows that error in console

@imsujan276
Copy link
Author

imsujan276 commented Jul 23, 2024

From what I understand from your stack trace, your are trying to upload by part and not with uploadWithUploadToken. Could you provide the real code sample?

Thank you @ThibaultBee, that error was on .upload and .uploadPart functions. I have updated the question

But still

the "video info in return" issue is in the .uploadWithUploadToken too.

final video = await ApiVideoUploader.uploadWithUploadToken(
        'UPLOAD_TOKEN',
        pickedVideoPath,
        onProgress: (progress) {
          EasyLoad.progress(
            percentage: progress,
            message: 'Uploading ${(progress * 100)}%',
          );
        },
      );
 print(video)

@ThibaultBee
Copy link
Member

About your first question, the reason is because the videoId you provide to createProgressiveUploadSession is incorrect. VideoId are given by api.video platform.
To create a videoId, see https://docs.api.video/reference/api/Videos#create-a-video-object

Also, it is not secure to store an API key in an application, see https://docs.api.video/sdks/security
Using an upload token is a better practice but it should not be store in your app as you won't be able to renew if needed.

For your uploadWithUploadToken snippet, could you provide the exact stacktrace?

@imsujan276
Copy link
Author

imsujan276 commented Jul 23, 2024

Here is the stacktrace for upload with token

I/OpenGLRenderer(12078): Davey! duration=128147ms; Flags=1, FrameTimelineVsyncId=25294, IntendedVsync=14184051429411, Vsync=14184051429411, InputEventId=0, HandleInputStart=14184052154706, AnimationStart=14184052155378, PerformTraversalsStart=14184052155623, DrawStart=14184052476069, FrameDeadline=14184118096075, FrameInterval=14184052149916, FrameStartTime=16666666, SyncQueued=14184053850563, SyncStart=14184054098675, IssueDrawCommandsStart=14184055248219, SwapBuffers=14184066646980, FrameCompleted=14312199662224, DequeueBufferDuration=1163905, QueueBufferDuration=848550, GpuCompleted=14312199662224, SwapBuffersCompleted=14184074171773, DisplayPresentTime=4294967295, 
I/ExoPlayerImpl(12078): Init 6dad796 [AndroidXMedia3/1.3.1] [emulator64_x86_64_arm64, sdk_gphone64_x86_64, Google, 31]
I/DMCodecAdapterFactory(12078): Creating an asynchronous MediaCodec adapter for track type video
I/CCodec  (12078): setting up 'default' as default (vendor) store
I/CCodec  (12078): Created component [c2.android.mpeg4.decoder]
I/CCodecConfig(12078): query failed after returning 9 values (BAD_INDEX)
I/MediaCodec(12078): MediaCodec will operate in async mode
I/MediaCodec(12078): [c2.android.mpeg4.decoder] setting surface generation to 12367874
I/CCodecConfig(12078): query failed after returning 9 values (BAD_INDEX)
I/CCodecBufferChannel(12078): [c2.android.mpeg4.decoder#967] Created output block pool with allocatorID 18 => poolID 62 - OK
I/DMCodecAdapterFactory(12078): Creating an asynchronous MediaCodec adapter for track type audio
I/CCodec  (12078): setting up 'default' as default (vendor) store
I/CCodec  (12078): Created component [c2.android.aac.decoder]
I/CCodecConfig(12078): query failed after returning 19 values (BAD_INDEX)
I/MediaCodec(12078): MediaCodec will operate in async mode
I/CCodecConfig(12078): query failed after returning 19 values (BAD_INDEX)
I/CCodecBufferChannel(12078): [c2.android.aac.decoder#192] Created output block pool with allocatorID 16 => poolID 63 - OK
I/WM-Processor(12078): Moving WorkSpec (93173795-9fe3-4ab9-97cb-372f9156da16) to the foreground
I/WM-SystemFgDispatcher(12078): Started foreground service Intent { act=ACTION_START_FOREGROUND cmp=com.livevibe.apps.dev/androidx.work.impl.foreground.SystemForegroundService (has extras) }
E/UploadWorker(12078): Upload failed
E/UploadWorker(12078): video.api.uploader.api.ApiException: Not Found: The requested resource could not be found.
E/UploadWorker(12078): 	at video.api.uploader.api.ApiClient.handleResponse(ApiClient.java:984)
E/UploadWorker(12078): 	at video.api.uploader.api.ApiClient.execute(ApiClient.java:884)
E/UploadWorker(12078): 	at video.api.uploader.VideosApi.uploadWithUploadTokenWithHttpInfo(VideosApi.java:1161)
E/UploadWorker(12078): 	at video.api.uploader.VideosApi.uploadWithUploadToken(VideosApi.java:890)
E/UploadWorker(12078): 	at video.api.uploader.api.work.workers.UploadWorker$doWork$video$1$future$1.run(UploadWorker.kt:81)
E/UploadWorker(12078): 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
E/UploadWorker(12078): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/UploadWorker(12078): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/UploadWorker(12078): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/UploadWorker(12078): 	at java.lang.Thread.run(Thread.java:920)
I/WM-WorkerWrapper(12078): Worker result FAILURE for Work [ id=93173795-9fe3-4ab9-97cb-372f9156da16, tags={ video.api.uploader.api.work.workers.UploadWorker, android-video-uploader, (videoId=hUoGBGwgrYeUwg==), (token=toXXXXXXXXX) } ]
I/WM-SystemFgDispatcher(12078): Stopping foreground service
[log] LOG => _uplaodVideoToAPiVideo() Exception: PlatformException(java.lang.UnsupportedOperationException, Not Found: The requested resource could not be found., java.lang.UnsupportedOperationException: Not Found: The requested resource could not be found.
      	at video.api.flutter.uploader.UploaderModuleImpl$uploadWithUploadTokenAndObserve$4.invoke(UploaderModuleImpl.kt:171)
      	at video.api.flutter.uploader.UploaderModuleImpl$uploadWithUploadTokenAndObserve$4.invoke(UploaderModuleImpl.kt:158)
      	at video.api.flutter.uploader.utils.LiveDataExtensionsKt$observeTillItFinishes$4.onChanged(LiveDataExtensions.kt:36)
      	at video.api.flutter.uploader.utils.LiveDataExtensionsKt$observeTillItFinishes$4.onChanged(LiveDataExtensions.kt:20)
      	at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
      	at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
      	at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
      	at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
      	at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
      	at android.os.Handler.handleCallback(Handler.java:938)
      	at android.os.Handler.dispatchMessage(Handler.java:99)
      	at android.os.Looper.loopOnce(Looper.java:201)
      	at android.os.Looper.loop(Looper.java:288)
      	at android.app.ActivityThread.main(ActivityThread.java:7839)
      	at java.lang.reflect.Method.invoke(Native Method)
      	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
      	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
      	 , null)

@ThibaultBee
Copy link
Member

ThibaultBee commented Jul 23, 2024

Have you set videoId parameter in uploadWithUploadToken? Leave to null or don't set if you don't have a videoId.

@imsujan276
Copy link
Author

imsujan276 commented Jul 23, 2024

When i dont set videoId, I dont get the error. still not getting the video response

Stacktrace:

I/OpenGLRenderer(12078): Davey! duration=326459ms; Flags=1, FrameTimelineVsyncId=26613, IntendedVsync=14304968091241, Vsync=14304968091241, InputEventId=127232446, HandleInputStart=14304969795673, AnimationStart=14304969796549, PerformTraversalsStart=14304969796855, DrawStart=14304995569777, FrameDeadline=14305001424573, FrameInterval=14304969770203, FrameStartTime=16666666, SyncQueued=14304995963994, SyncStart=14304996412770, IssueDrawCommandsStart=14304996545587, SwapBuffers=14304997319128, FrameCompleted=14631428487287, DequeueBufferDuration=2027509, QueueBufferDuration=741862, GpuCompleted=14631428487287, SwapBuffersCompleted=14305000684932, DisplayPresentTime=0, 
I/ExoPlayerImpl(12078): Init 9d896f8 [AndroidXMedia3/1.3.1] [emulator64_x86_64_arm64, sdk_gphone64_x86_64, Google, 31]
I/DMCodecAdapterFactory(12078): Creating an asynchronous MediaCodec adapter for track type video
I/CCodec  (12078): setting up 'default' as default (vendor) store
I/CCodec  (12078): Created component [c2.android.mpeg4.decoder]
I/CCodecConfig(12078): query failed after returning 9 values (BAD_INDEX)
I/MediaCodec(12078): MediaCodec will operate in async mode
I/MediaCodec(12078): [c2.android.mpeg4.decoder] setting surface generation to 12367876
I/CCodecConfig(12078): query failed after returning 9 values (BAD_INDEX)
I/CCodecBufferChannel(12078): [c2.android.mpeg4.decoder#115] Created output block pool with allocatorID 18 => poolID 66 - OK
I/DMCodecAdapterFactory(12078): Creating an asynchronous MediaCodec adapter for track type audio
I/CCodec  (12078): setting up 'default' as default (vendor) store
I/CCodec  (12078): Created component [c2.android.aac.decoder]
I/CCodecConfig(12078): query failed after returning 19 values (BAD_INDEX)
I/MediaCodec(12078): MediaCodec will operate in async mode
I/CCodecConfig(12078): query failed after returning 19 values (BAD_INDEX)
I/CCodecBufferChannel(12078): [c2.android.aac.decoder#227] Created output block pool with allocatorID 16 => poolID 67 - OK
I/WM-Processor(12078): Moving WorkSpec (2df38861-53f3-42e7-bac7-1ebe12c3d029) to the foreground
I/WM-SystemFgDispatcher(12078): Started foreground service Intent { act=ACTION_START_FOREGROUND cmp=com.livevibe.apps.dev/androidx.work.impl.foreground.SystemForegroundService (has extras) }
I/WM-WorkerWrapper(12078): Worker result SUCCESS for Work [ id=2df38861-53f3-42e7-bac7-1ebe12c3d029, tags={ video.api.uploader.api.work.workers.UploadWorker, android-video-uploader, (token=toXXXXXXX) } ]
I/WM-SystemFgDispatcher(12078): Stopping foreground service

@imsujan276
Copy link
Author

Exact code i am using

void _uploadVideoToAPiVideo(String videoPath) async {
    try {

      final video = await ApiVideoUploader.uploadWithUploadToken(
        'UPLOAD_TOKEN',
        videoPath,
        onProgress: (progress) {
          EasyLoad.progress(
            percentage: progress,
            message: 'Uploading ${(progress * 100)}%',
          );
        },
      );
      log('LOG => _uplaodVideoToAPiVideo() Success: ${video.videoId} | ${video.assets?.mp4} | ${video.assets?.player}');
    } on Exception catch (e) {
      log('LOG => _uplaodVideoToAPiVideo() Exception: $e');
    } catch (e) {
      log('LOG => _uplaodVideoToAPiVideo() Error: $e');
    } finally {
      EasyLoad.dismiss();
    }
  }

@ThibaultBee
Copy link
Member

Do you have anything after I/WM-SystemFgDispatcher(12078): Stopping foreground service?

Could you test on the provided example?

@imsujan276
Copy link
Author

Stopping foreground service is the last line

@imsujan276
Copy link
Author

imsujan276 commented Jul 23, 2024

the example seems to return the video object in response

when i use the same upload code inside my function _uploadVideoToAPiVideo, it does not print out the video

@ThibaultBee
Copy link
Member

ThibaultBee commented Jul 23, 2024

I put your code in the example (without EasyLoad). I get:

I/WM-SystemFgDispatcher(23622): Stopping foreground service
[log] LOG => _uplaodVideoToAPiVideo() Success: viXXXXX | https://vod.api.video/vod/viXXXXX/mp4/source.mp4 | https://embed.api.video/vod/viXXXXX

So it works.

@imsujan276
Copy link
Author

let me check that again

@imsujan276
Copy link
Author

even after removing the EasyLoad part, it does not seem to log the video info in my code

@ThibaultBee
Copy link
Member

Is there something in your application that could unregister workmanager observer, live data or play for livecycle?

As it works with the example, there is definitely something in your application that changes the behavior of the uploader, thus it is almost impossible to assist you with this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants