Anki Forums

Error adding Anki deck from weblink

Hello Damian,

I have a curious error and I’ve been going round in circles trying to resolve it.

I provide Anki decks to my students to download to their AnkiMobile app. The only way that seems to be available is to provide a download link. But now I’m getting the error: “File invalid or corrupt”.

Now, it may be because the link is to a protected folder. So I first go to Safari and log in. And THEN I go back to Anki and download the file. But this still doesn’t work. I’ve also tried to download the file first and then select Export: “Open in Anki”, but nothing happens when I do this (after having fully downloaded the file).

I’m not sure how I did it before, because it did work - maybe with a previous version of the app, I can’t remember.

The files open without error directly in the Windows version of Anki. So they obviously are NOT corrupt or invalid.

[I’m trying to avoid having to instruct my students to use the sync method from their computer because it is so complicated that I have to walk each of them individually through the process, and I don’t have the time to do that any more. The only other solution I have as a workaround is to manually create an account for each student on ankiweb, and then upload the Anki files for them to sync down to their iPhones (and also Android devices). But even this is cumbersome and time-consuming. I don’t have enough space on my hard drive to keep separate accounts for over 1000 students (each with around 200MB of data files). So I just upload to your server and delete their media folders on my drive, hoping that I never have to access their profile again on my PC… :o]

For now, can you think of why I get the invalid/corrupt error? Do I need to re-export the decks from the Windows version, or is there another way to import a deck into AnkiMobile directly (without having to sync from the desktop computer)?

Any ideas or suggestions? Or is this an obscure bug in Anki, and we have to wait for a new release sometime in the future…?

Many thanks,
Gary

UPDATE:

I created a new link to a public folder on my server and started the download using the unrestricted weblink.

The file did download successfully (like in Safari)… but I got strange numbers like this:
Downloading… -359283487234987234%

So the issue is really that the app doesn’t have a mechanism to log in to a protected folder and so the error message is misleading. The file isn’t invalid or corrupt, the permission to access it has been denied by the server.

Is this something you can fix, or is there a workaround?

I don’t know why the Export/Open In function doesn’t work at all. Maybe this is an error in IOS (currently 14.1) or maybe I have to somehow identify or activate Anki as a valid app for apkg files…?

There are a couple of other related errors I’ve discovered.

Firstly, most of the linked or button text is invisible in dark mode, but is also not visible on the Windows version of Anki, and even when I force dark mode off in the app.

So what am I doing wrong in the code/CSS below?

UPDATE:

I created a new link to a public folder on my server and started the download using the unrestricted weblink.

The file did download successfully (like in Safari)… but I got strange numbers like this:
Downloading… -359283487234987234%

So the issue is really that the app doesn’t have a mechanism to log in to a protected folder and so the error message is misleading. The file isn’t invalid or corrupt, the permission to access it has been denied by the server.

Is this something you can fix, or is there a workaround?

I don’t know why the Export/Open In function doesn’t work at all. Maybe this is an error in IOS (currently 14.1) or maybe I have to somehow identify or activate Anki as a valid app for apkg files…?

There are a couple of other related errors I’ve discovered.

Firstly, most of the linked or button text is invisible in dark mode, but is also not visible on the Windows version of Anki, and even when I force dark mode off in the app.

So what am I doing wrong in the code/CSS below?

{{#sentence1}}
<span class="thaisentence">{{sentence1}} {{sentence1audio}}</span><br>

<input type="button" class="button" value="English" onclick="document.getElementById('translation1').className += ' shown'; this.style.display = 'none'; return false;">

<div id="translation1" class="translation">{{English sentence 1}}</div>
{{/sentence1}}

.translation.shown {
display: block;
}

.button {
color: #0000;
font-size: 12px;
width: 60px;
height: 14pt;
border: none;
margin: 10px;
padding: 1px;
background: #0dd0;
}

.button:hover {
background-color:#819FF7;
}

Secondly, there doesn’t seem to be a way to stop auto play of the audio in AnkiMobile. The play buttons appear correctly, but ALL the audio on the card plays one after the other immediately when it is opened.

On Windows there is a General option for each deck to switch off auto play. Where is this option in the AnkiMobile app?

Thanks and regards,
Gary

The download link feature will not work with websites that require you to log in. It’s provided for use in certain school environments, where students don’t have access to the Safari app.

If you have access to Safari, you should be able to download an .apkg file, then use the “Open in Anki” option. If that is not working, maybe your server is not sending the files using the correct content type? Can you share a link with me via private message?

You are right that there are a number of ways the download link feature could be improved, but this is not a high priority at the moment, as it is only intended for use in environments where Safari is not available.

I entered in the link you posted into Safari, and it finished after 84MB was downloaded. I tapped on the Download arrow in Safari, tapped on the name of the deck, and then Open in Anki, and it began importing. I received an “Import Complete” message, and the deck appears in the deck list. This worked for me both on an iPad and an iPhone. Maybe your download is being interrupted by temporary network issues, or you have some other app installed that is trying to open the file instead of AnkiMobile?

That’s very curious that you can download the and import the file when I and many of my students can’t. It may be some obscure configuration setting in IOS that prevents apkg files from being opened when you select “Open in Anki”.

It is quite a priority, actually - at least for my customers (roughly 1,500 so far). About half have already purchased AnkiMobile from the app store, the rest are using their desktop or an Android device.

The download and installation/setup debacle has been going on for so long now that the majority have said they’ve given up trying to use Anki. Those who want to persevere either spend several hours trying to figure it all out - or I usually step in and set it up for them on my PC and then sync to their account on AnkiWeb so that they can get it into the smartphones.

It’s not necessarily anything to do with Safari either. It just happens to be the browser most IOS users have, but it could be any browser. The problem is that, once downloaded to the phone, the file isn’t being opened/imported in Anki (most of the time).

I will talk to some app developers in our group and ask them if it’s an app issue or an IOS issue.

Yes - network issues can exacerbate the problem, perhaps because the files are so large. However, I even experience problems on my 100Mbps fiber internet connection (which drops to 20Mbps when connecting to my server in the USA).

It may also be an IOS issue where background downloading is interrupted if the phone is auto-locked, and maybe there is a setting for apps like Anki to allow it to continue even while locked. (However, when I looked for the Anki app in Settings, but I didn’t find it listed.)

It may also be that Anki is designed for tech-savvy people who want to produce their own personal decks of cards, and not something for the general user. Unfortunately, the other flashcard systems I’ve looked at don’t have the kind of developer flexibility (in my case, the hint buttons, and ability to display sample sentences and hidden translations in the answer side of the card).

Your webserver is not reporting the file length, which may be obscuring when the connection is being terminated abruptly instead of succeeding - you can tell by the fact that it shows eg “13.5MB of ?” in the Safari download screen. Your webmaster may be able to help you with fixing that.

iOS will suspend apps (and thus break downloads) within a few minutes if the screen is turned off, but I imagine iOS may well treat Safari differently, and allow downloads from it to continue even with the screen off.

OK, the download via the weblink issue has been resolved.

For future reference, the following line needs to added to your .htaccess file (Linux/Unix servers):

SetEnv no-gzip dont-vary

However, for some reason, the file downloaded via Safari won’t Open in Anki. But I just tested it with Google Chrome - it imports directly into Anki without a problem when you select “Open in…” and select Anki.

So it seems to be a Safari configuration or compatibility issue then… right? Any ideas on how to fix this?

I tried the link you previously posted again, and Safari showed download progress this time. When I tapped on it after it finished downloading, it imported correctly for me.