strapi-provider-upload-azure-storage icon indicating copy to clipboard operation
strapi-provider-upload-azure-storage copied to clipboard

Invalid URL when uploading images using sasToken

Open cj11489 opened this issue 2 years ago • 5 comments
trafficstars

Hi @jakeFeldman thanks for publishing v3.2.0; however, I have run into an error when uploading an image via the strapi media library when using the sasToken.

The BlobServiceClient throws a TypeError [ERR_INVALID_URL]: Invalid URL error. I believe its caused because the sasToken is just being appended to the baseUrl rather than being added as a query parameter:

return new BlobServiceClient(`${serviceBaseURL}${sasToken}`, anonymousCredential);

I believe it needs ? adding between the two variables:

return new BlobServiceClient(`${serviceBaseURL}?${sasToken}`, anonymousCredential);

cj11489 avatar Oct 16 '23 10:10 cj11489

For now can you add the "?" to your sasToken? I can patch and update the docs to reflect this later today.

jakeFeldman avatar Oct 16 '23 13:10 jakeFeldman

Will do. Thanks @jakeFeldman

cj11489 avatar Oct 16 '23 14:10 cj11489

@jakeFeldman I would like to re-open this bug. Apparantly the urls that are stored in the database are too long. I get a "Data too long for column" error on the url field of the file. This is probably caused by the SASS token that is added in the database along with the file name.

Is this something that can be fixed?

kevinvugts avatar Nov 27 '23 11:11 kevinvugts

@jakeFeldman I would like to re-open this bug. Apparantly the urls that are stored in the database are too long. I get a "Data too long for column" error on the url field of the file. This is probably caused by the SASS token that is added in the database along with the file name.

Is this something that can be fixed?

I encounter the same issue.

But I found a solution.

Don't use SAS at all. Remove the sasToken property and use only accountKey

andreiwow2 avatar Feb 02 '24 14:02 andreiwow2

@kevinvugts sorry for the delayed response. The sasToken was added at a later date and the original implementation was for accountKey only. It's might be possible to fix what's gets saved to the db. Not sure if strapi exposes any apis that allow for this. Obviously this plugin doesn't write to the db directly.

jakeFeldman avatar Feb 02 '24 15:02 jakeFeldman