File upload and storage

Hi!

I’m confused about the whole Storage system. I’m using curl to access the Crowding V2 API.

So according to the documentation:
Storage is a separate container for each file. You need to use Add Storage method before adding files to your projects via API. Files that should be uploaded into storage include files for localization, screenshots, Glossaries, and Translation Memories.

Storage id is the identifier of the file uploaded to the Storage.

Note: Files uploaded to the storage are kept during the next 24 hours.

From the documentation above I understand that the file contained by the storage will get deleted after 24 hours but it’s not clear if the storage itself gets deleted.

So that means that each time I need to translate a file I first need to add a storage, but that means that after a while of using the service, we’ll have a bunch of useless storages. Do I need to take care of that? Should I delete the storages or does that gets taken care of by Crowdin?

It would be nice to have some examples of the API usage instead of just individual endpoints and a few words about each class of endpoints.

Thanks!
Razvan

Hello @razvan.soare_ext

In general, Storage is 1 for the whole account, and you’re right, files in the storage are automatically cleaned within 24 hours.

There is a specific call to delete storage(s) but it is used rarely, only if you need to clean up files in an urgent manner. So, in general, you may just use the Add Storage method and the rest will be done by Crowdin.

Regarding some specific samples, most of them are oriented on the client usage (for example, this one)

But, here’s a basic example using curl:

Thank you for the sample, but what would be an equivalent of getting the translated file with the API.

Hi @razvan.soare_ext ,

If you mean exporting the translations via API, then the following methods would be needed (Build and Download Project Translations):
https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.post
https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.download.download

In case you want to upload translations to your project, then it would be necessary first to create the Storage for the file with translations and then upload this file using the Upload Translations method:
https://developer.crowdin.com/api/v2/#operation/api.projects.translations.postOnLanguage

Thank you! That confirms some of my hunches.

Hi, again!

Still related to this topic. I managed to make it work for iOS uploading a “Localizable.strings” file, but when I try to do the same for Android, the Add File API fails with this error:

{"errors":[{"error":{"key":"storageId","errors":[{"code":"fileInvalid","message":"The imported ANDROID localization file is invalid. XML validation module said: Start tag expected, '<' not found\n. Total errors: 1"}]}}]

At first glance it’s pretty clear what it’s saying, the XML doesn’t start with a proper tag but the XML does start with a proper tag. The first 2 lines from the XML are:

<?xml version="1.0" encoding= "utf-8"?>
<resources>

The XML file was validated with 3rd party tools and it also works inside the Android app.

I initially thought that maybe I’m uploading the wrong file or from a wrong location but it’s not the case.
Also this works fine with Crowdin API v1 but v2 doesn’t like the XML for some reason.

Can you please help with this issue? Is there something I’m missing?

Thanks!
Razvan

Hi @razvan.soare_ext could you please share the source file with us on support@crowdin com? and please also mention there the name of the project

Thanks! I sent an email to support.