aws-sdk-js icon indicating copy to clipboard operation
aws-sdk-js copied to clipboard

Location URL misses https://

Open petersg83 opened this issue 3 years ago • 2 comments

Describe the bug

When using S3.upload and upload a large file (~21Mo in my example) the url given by Location property misses the "HTTPS://" part . I use Digital Ocean Spaces. I reached to them and said it is more likely coming from the sdk.

First console.log : small file (<1Mo) Second console.log : large file (~21Mo) DO spaces

Expected Behavior

I expect the Location url to contain the http protocol.

Current Behavior

The Location url doesn't contain the http protocol.

Reproduction Steps

The bug can be reproduced by using Strapi, the AWS upload provider and Digital Ocean Spaces. More details here: https://github.com/strapi/strapi/issues/14288

The code using AWS is there: https://github.com/strapi/strapi/blob/main/packages/providers/upload-aws-s3/lib/index.js#L37

Possible Solution

It is possible it comes from a different way of setting the Location property depending on if the request is multipart or not.

Additional Information/Context

No response

SDK version used

Tried with 2.1209.0 and 2.1188.0

Environment details (OS name and version, etc.)

MacOS 12.5.1

petersg83 avatar Sep 05 '22 07:09 petersg83

Hey @petersg83 thanks for opening this issue, can you please share more details on how to reproduce this using Starpi as Iam not so familiar with those?

ajredniwja avatar Sep 06 '22 15:09 ajredniwja

@ajredniwja : I reported this issue to Strapi. details are in the forum link below.

https://forum.strapi.io/t/video-preview-not-working-when-using-strapi-with-digitalocean-spaces/21716

The issue persists when a video is uploaded over 50MB which ends us stripping the https:// from the link

m90khan avatar Sep 09 '22 09:09 m90khan

Hey @petersg83 thanks for opening this issue, can you please share more details on how to reproduce this using Starpi as Iam not so familiar with those?

Hello @ajredniwja I have tested it with Strapi using a video .mov which weight >20,6mo, when uploading throught the AWS S3 sdk (see Strapi implementation here) using the 'aws-sdk' nodejs package, the url returned by this upload is different from smaller video file.

Here is a smaller video url: https://{bucketName}.fra1.digitaloceanspaces.com/{video_filename}.mov And here is the url I got with bigger video file: fra1.digitaloceanspaces.com/{bucketName}/{video_filename}.mov.

As you can see, the protocol is missing and the domain changes between the two upload, which should not be the case if we want to remain consistent (is it possible?).

nathan-pichon avatar Nov 08 '22 09:11 nathan-pichon

@nathan-pichon : This is the same issue that I described here https://forum.strapi.io/t/video-preview-not-working-when-using-strapi-with-digitalocean-spaces/21716 and hence strapi opened this ticket with was.

For the time being, check on the URL string and set conditional accordingly on the frontend side does the job.

m90khan avatar Nov 08 '22 13:11 m90khan

I am getting a different URL from Digital Ocean Spaces as well, when I upload PNG's over 5mb

laurenskling avatar Nov 25 '22 19:11 laurenskling

Has this been fixed? Having the same issue

Nijinsha avatar Jun 20 '23 11:06 Nijinsha

Hi,

The SDK doesn't guarantee support with 3rd party offerings like digital ocean.

Moreover location is returned from the service, so this is a service side behavior, not a client behavior. The client deserializes the response based on the protocol in which data is returned. S3 uses XML. Since you are not using S3 and instead using Digital Ocean as your storage layer, it's up to them to make sure: A. The returned data is in the correct format (in this case location with http:// B. If the data is returned correctly, it might be formatted in a way that doesn't not comply with the SDK serialization scheme for XML leading to malformed data (unlikely in this case)

The workaround here is either to move to S3 which the SDK supports natively. Or like @m90khan mentioned, check if the return location string contains an https:// prefix and if not just add it to the beginning.

At any rate, this is not an SDK issue and is not actionable by the team.

Thanks, Ran

RanVaknin avatar Jun 21 '23 01:06 RanVaknin