-
Notifications
You must be signed in to change notification settings - Fork 26
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
Uploading multiple images on iOS devices failing #59
Comments
Could you please share a working (minimum) code for me to reproduce this issue? |
I've attached a minimum code working example.
You'll then see the mentioned errors. Also note the network tab shows only 1 call to the server (for all 5-10 images) You can also then try this on Google Chrome and see that it works as intended, on the network tab you will see 1 call to the server for every image uploaded |
Got the issue reproduced, Safari just doesn't seem to respect any header. Before I release the SDK, can you confirm if the below bundle works for you? Its only for testing, please do not use it in production. |
Hi, I've tried using the script above, the problem still exists. Perhaps make some configuration options to allow requestType to be post? This way it won't be such a breaking change. |
It is not possible to cache anymore because the URL is different. Can you share the code with the above code bundle not working? |
Exact same bundle I uploaded before with the following changes: Added to index.html: <script type="text/javascript" src="https://ik.imagekit.io/demo/img/imagekit.min_ZkfCXeHcx.js?ik-sdk-version=javascript-1.4.3&updatedAt=1656997731049"></script>Removed "import ImageKit from "imagekit-javascript" from HelloWorld.vue (as we're using the CDN script) The rest remains the same:
} |
The problem still persists on my end, I have noticed however the new script is an improvement, on the original package, it will make 1 or 2 network calls at most until cached (test with 8 images), on the new package it made 5 network calls (test with 8 images) until it cached (not sure how it's caching with randomised URL's?). With original package: With new script: |
The new bundle worked as intended on both Google Chrome & Safari. Haven't been able to test on an iOS device yet but it seems to be right. |
Fixed in 1.5.2 |
Hi,
We are getting the following error when uploading files from Safari (using client side upload with the JS SDK:
"The token with value '8cbdb59b-6246-4f8f-b0e0-77b34c4e9e63' has been used before. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions.”
The first file (in a list) will work, while the following fail. This error is only occurring on iOS devices.
Near identical issue (however it's using Uppy):
imagekit-developer/imagekit-uppy-plugin#3
After some debugging I have noticed that on an Android device, or a computer, running a for loop to upload images ImageKit will call the our cloud function to retrieve
authenticationParameters
for every single iteration, however, on an iOS device the cloud function will only be called on the first iteration. Based on the issue above, it seems like it's caching the result on iOS so it doesn't need to make the same call again. Issue is this is causing subsequent uploads to fail......A potential fix could be to do the following after line 68 at
imagekit-javascript/src/utils/request.ts
Line 68 in 8afc7ed
xhr.setRequestHeader('Cache-Control', 'no-cache');`
Edit:
After much trail and error I have found the only way to solve the issue is by making the call to
authenticationEndpoint
a POST request. I have tried adding every form of cache control header (both on server & client), however Safari ignores all of them.Suggested fix: Change API call to authenticationEndpoint from GET to POST request
Code for reference:
Initialise Imagekit:
new ImageKit({
publicKey: "PUBLIC_KEY",
urlEndpoint: "URL_ENDPOINT",
authenticationEndpoint: "API_ENDPOINT,
}),
Authentication endpoint (cloud function):
exports.createImageKitSignature = functions
.https.onRequest((req, res) => {
cors(req, res, () => {
const authenticationParameters = imagekit.getAuthenticationParameters()
res.status(200).send(authenticationParameters)
})
})
Upload function:
The text was updated successfully, but these errors were encountered: