Same filename results in second upload failing silently

I found a previous topic which was never responded to, it asks my question perfectly. Same file name issue on Steam

Basically I have a use case where multiple of my users could upload a video with the same filename and right now that would result in the subsequent uploads essentially doing nothing.

Even if I modify the filename (in metadata) before upload it still results in the subsequent uploads not being created in Stream. Stream correctly shows my unique filename with my unique prefix but this is not enough to trick Stream into allowing the same video to be uploaded twice.

Any tips here? I would hate for 2 of my users to go to Pexels and grab the same stock video and then the second user would not be able to upload the video to my site.

The Stream API does not care about filenames. In the example you share, the 2 users should have absolutely no problem uploading files with the same name. If you are seeing a different behavior, can you share the steps to reproduce the issue?

1 Like

Hey @zaid thanks for the fast response, I’ll try my best to give you something workable here. Below you will see my 2 request for uploading the same file (derek-123.mp4) and some of the request/response data I see in devtools.

First Request

Filename: derek-123.mp4
Direct creator upload URL (using CF Worker): https://upload.videodelivery.net/tus/b56d60a1d76e10bd1e24b1bc546eef23?tusv2=true
Request Method: PATCH
Status Code: 204

RESPONSE HEADERS
access-control-allow-headers: Origin, Tus-Resumable, Tus-Version, Location, Upload-Length, Upload-Offset, Upload-Metadata, Tus-Max-Size, Tus-Extension, Tus-Resumable, Upload-Defer-Length, X-HTTP-Method-Override, Content-Type
access-control-allow-methods: GET, POST, PATCH, HEAD
access-control-allow-origin: *
access-control-expose-header: cf-ray
access-control-expose-headers: Tus-Resumable, Tus-Version, Location, Upload-Length, Upload-Offset, Upload-Metadata, Tus-Max-Size, Tus-Extension, Content-Type, Stream-Media-ID
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400
cache-control: private
cf-cache-status: DYNAMIC
cf-ray: 6ac19b798cdcf4b2-YVR
date: Wed, 10 Nov 2021 19:15:05 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
served-in-seconds: 0.296
server: cloudflare
stream-dw-version: 2021.11.6
stream-media-id: b56d60a1d76e10bd1e24b1bc546eef23
strict-transport-security: max-age=15552000
tus-resumable: 1.0.0
upload-offset: 4834602
vary: Origin, Accept-Encoding
x-content-type-options: nosniff

Second request

Filename: derek-123.mp4
Direct creator upload URL (using CF Worker): https://upload.videodelivery.net/tus/b56d60a1d76e10bd1e24b1bc546eef23?tusv2=true
Request Method: HEAD
Status Code: 200

RESPONSE HEADERS
access-control-allow-headers: Origin, Tus-Resumable, Tus-Version, Location, Upload-Length, Upload-Offset, Upload-Metadata, Tus-Max-Size, Tus-Extension, Tus-Resumable, Upload-Defer-Length, X-HTTP-Method-Override, Content-Type
access-control-allow-methods: GET, POST, PATCH, HEAD
access-control-allow-origin: *
access-control-expose-header: cf-ray
access-control-expose-headers: Tus-Resumable, Tus-Version, Location, Upload-Length, Upload-Offset, Upload-Metadata, Tus-Max-Size, Tus-Extension, Content-Type, Stream-Media-ID
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400
cache-control: private
cf-cache-status: DYNAMIC
cf-ray: 6ac19e6b7c3761f9-YVR
date: Wed, 10 Nov 2021 19:17:03 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
served-in-seconds: 0.005
server: cloudflare
stream-dw-version: 2021.11.6
stream-media-id: b56d60a1d76e10bd1e24b1bc546eef23
strict-transport-security: max-age=15552000
tus-resumable: 1.0.0
upload-length: 4834602
upload-offset: 4834602
vary: Origin, Accept-Encoding
x-content-type-options: nosniff

My new theory

From looking at the above it appears to me that maybe the issue is that my CF Worker is returning the same upload URL? I am using the standard code found in the guide here: https://developers.cloudflare.com/stream/uploading-videos/direct-creator-uploads#using-tus-recommended-for-videos-over-200mb

Am I missing something in a request to my CF Worker?

Thanks in advance,

Derek

I would look into your Worker code, in particular, your caching settings. The quickest way to confirm it is a worker issue might be to bust the cache by adding a querystring parameter to the subsequent worker request that is returning the one-time upload URL. The fact that you are seeing the same one-time upload URL tells me this is likely a Worker-cache issue.

1 Like

Thanks @zaid! You led me down the right path. Caching was my issue, but it was not with my Worker. Instead my issue was that I am implementing my client-side uploads using Uppy + tus plugin which builds upon tus-js-client. tus-js-client has some functionality (removeFingerprintOnSuccess) that caches a fingerprint in the user’s browser to prevent requesting a tus upload URL every time a file is uploaded.

All is up and running on my end now. Thanks again @zaid

1 Like

Great to hear @derekps!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.