Issue downloading files
-
I have heard here someone might use BunnyCDN for product distribution (@d-healey maybe?)
I encounter a strange and annoying issue when trying to download the products from another computer.First of all, everything works smoothly from my main development computer.
It works nicely too from a VM in this very same computer.But when using another computer, (being an old mac or the same than my development mac but from a client), download the products leads to a download error
this.data.success
returnsfalse
The way I handle things is via two plugins from my server.
- one from getting a token secure URL
- one for listing the product folders/assets
so the download from Hise (or from the exported binary) is straight forward.
- set the base URL with the token secure URL
- download the asset I need with the habitual download function.
Trying to download a file from a permanent link in my WP server works, so the issue is with CDN storage only
I have been looking everywhere in the BunnyCDN settings (CDN and Storage) with no clue whatsoever
I use the Token Authentication, but NOT the Token IP Validation, since I know it can lead to issuesSo what could be wrong downloading from any other computer than the one used for development?
-
I switched over last month and got my first bill a few days ago, it is sooo much cheaper than Amazon :)
For my products I don't interact directly with Bunny's API.
I use the WooCommerce plugin and my HISE project requests downloads from the WooCommerce API through a separate Wordpress plugin that I wrote.
In your case I don't know what the issue could be.
-
@d-healey Yeah I agree it seems very cheap!
Arff... Thanks, hopefully someone will chime in with experience on this particular issue
-
That gets stranger and stranger...
So I checked with the support and it is not a CDN issue.
This can easily be checked when opening this URL in a browser, the file downloads as it should on any computer:
(the expiration is set to approx 24h)
https://s427.b-cdn.net/bcdn_token=hva8kCEAjQ2HvytakhRVy4JPVG54j3iS5Rb7K7SYEZI&expires=1726145586/assets/Align-IT/Align-IT v1.0.0.pkg
However doing this within Hise (or exported binary) only works on my main computer, but not in any other one! So what could be the reason?
Here's a simple snippet using this same URL to demonstrate the issue (unless it works on your side, which would drive me crazy for good!)
HiseSnippet 1049.3ocsVstaaaCElxIpnxaEXEXO.B9GCJXIJ1o1IAMHcMwWZ7ZRpWTZvtfg.FIZKVSSJPR6Uih73s2m8FrcnjrsbqWZmAlLrE445GO7vO5dRQHQoDRjky0SSHHqu1NXJWG2LFS4ntsPVOwtk3O3LANpYqKQmNMAqTjHjk0FuxXhkylnzm+5GNEyv7PxBQHzMBZH4b5Hpdgzdu70TF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taMT5Iih04QvEx2FFtbn9DG2acc7Yqqi0WWGartNt+553AqqiG94cz7+kNYrVLJ6XCBcQu1oTIVVs4XnCLsaE8OP8YFDK
I'll provide a new link when needed when this one expires
I also tried to place the parameters in, well, the parameters of the download function, but that doesn't work and might not be clever anyway...
-
@ustk Oh I didn't realise you were using the CDN for this. That's doesn't seem like a good idea, you should use the object storage.
-
@d-healey Thanks, but what do you mean by this? Could you please extend a wee bit?
-
@d-healey I think I use it the way they want you to do.
They say it is forbidden to deliver files directly from the storage, as it is a violation.
The storage has to be linked to a Pull Zone, so the request is made to that PullZone -
@ustk said in BunnyCDN issue when downloading files:
The storage has to be link to a Pull Zone
Yes correct, it works just like S3 storage but is much simpler to set up.
-
So now I am sure... This is driving me nuts for good...
I put together a new snippet that requests the secure URL and tries to download the file on success
HiseSnippet 1328.3ocsVstaaaCElJIpXxacXEXO.bd+QAMQNoqqcnEYyw2ZMZhsQjS69WFiDcLWjIMHoRpQQd21izdC1NjRxRt1caHX0IHwj7bN7iemqijhHpRIjHGuwKlSQNeka3BtdZ6oDFG0uCx4gtcD2xSDj31cFfZsXNQonwHGmsekQDGucP1O+4uzhjP3QzxsPn2JXQzSXyX5xcG07MrjjdjX5X1rJR+zl8iD71hDQJ.mscO.MmDcM4J5.hQrsbQNOnaLSKjgZhlpPN6zRDuHbJ.uL4eKSwtLgZVbHJDLT118DIwFDa1E0dJKIdTwyVg.qLpjD1NiD9V2SYwrk6WRFei8.boFU4CmsVEdauB7NrJ7NnB71.jbp.ocxfzibCijr45xSL34Kc6y0T4DBP6UgRlrns99G31V.Rv0AyHWS6IgEK0v+YGbvdX3O69xZfTJQBMHJgRj9vF0pANCkFeCQhacbX2KN+rSvdddGgqOUqmqdQiF2d6sAJcZLS7zm7bh4+AQhY0eYEMCGO7rieU2KJsPE8UfZAWteTLOfS0M1nh85eRohGmvthue+wMJ9B9lCCN.9Y90WU2.4FMvup6XbX21meVW73guo6.LnbMFOgwo3Io7HMSvwBdbdLcKM2P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hO69p3yuuJ9S+6JZJYbbpVLKKsAgNcTWa8OGmt1ZJ1nUzeCj7miqN
Here's the problematic response I instantly get from other computers than mine, what about yours?
Interface: { "numTotal": 0, "numDownloaded": 0, "finished": true, "success": false, "aborted": false }
As I said, the response is instantaneous, no waiting time that could tell that it is a server issue (at least to me...)
- Could someone tell if it works or not from his computer?
- Could it be a Hise setting, compile flag, or whatever I do on my side?
I would have preferred it not to work at all, as it would have been simpler to track down, so why it's working on my computer only?
The PHP part on my server that outputs the secure token URL:
function rest_route_secure_token_callback(WP_REST_Request $request) { $base_url = "https://s427.b-cdn.net"; // The CDN Pull Zone (bunnyCDN) $folder = '/assets/'; // Folder we want access to $url = $base_url . $folder; $securityKey = 'my-real-security-key-I-dont-wanna-show-publicly'; // Url Token Authentication Key $expiration_time = 3600; // Expiration (1h) $user_ip = NULL; // IP Validation is not reliable enough (disabled in the Bunny CDN dashboard) $is_directory_token = true; // Grant access to the directory instead of unique files $securedURL = sign_bcdn_url($url, $securityKey, $expiration_time, $user_ip, $is_directory_token); //function sign_bcdn_url($url, $securityKey, $expiration_time = 3600, $user_ip = NULL, $is_directory_token = false, $path_allowed = NULL, $countries_allowed = NULL, $countries_blocked = NULL, $referers_allowed = NULL) header('Content-Type: application/json'); header('Content-Transfer-Encoding: UTF-8'); header('Expires: 0'); $response = array( 'result' => 'success', 'code' => "200", 'message' => 'URL generated', 'url' => $securedURL ); $json = json_encode($response); echo $json; }
-
Ok so after further testing, I've been able to find the culprit do be the spaces in the URL!
So doing a basic sanitisation like
url = url.replace(" ", "%20");
seems to do the trick
Now, even if taking care of spaces in a URL might seem a normal thing to do, why it was working on only 1 over 4 tested computers makes no sense to me...
-
@ustk Were all computers using the same OS and HISE version?
-
@d-healey same OS on two of them, one M3 Pro (mine which works) and the other M1 (which didn't work)
Other macs are old one, like 2011 and 2013 intelTried with both Hise (on the two M1+ macs) and exported binary (on all of them)
Hise were the same on 2 macs (direct Hise binary copy, not build)Maybe the sanitisation could be directly handled by the download API...
-
@ustk are the spaces in your file names? I always replace mine with underscores to avoid these kind of issues.
-
@d-healey Exact, in the filenames.
I do replace them with underscore to as for the JSON files, but binaries I like them with spaces... That been said, I could replace the underscores with spaces when writing the files...