-
Notifications
You must be signed in to change notification settings - Fork 55
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
Type issue inside addStorage #227
Comments
Hum I looked at the debugger before changing the string to a buffer and they both have the correct content type, only diff between the 2 requests is the type of data inside the request. I changed my code from: const storage = await uploadStorageApi.addStorage(path.basename(crowdinFile), await readFile(sourceFile, 'utf-8)) to const storage = await uploadStorageApi.addStorage(path.basename(crowdinFile), await readFile(sourceFile)) |
Fixed in v1.21.2 const contentString = fs.readFileSync(file, 'utf8');
const contentBuffer = fs.readFileSync(file);
//both options now will produce file with correct type
await client.uploadStorageApi.addStorage(file, contentBuffer);
//or
await client.uploadStorageApi.addStorage(file, contentString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey 👋
I spent quite a few minutes trying to understand why my upload failed.
I was sending a JSON file and got a ...
type: chrome
from the API instead of thecustom_fomat
I was expecting (what I have if I upload via the UI).Based on the source I had no idea what the lib wanted to have
So I looked into the tests and ok, you use a string https://github.com/crowdin/crowdin-api-client-js/blob/master/tests/uploadStorage/api.test.ts#L21
nope 😁
We must send a buffer in order to have the API doing its magic to get the correct type value (as sending a
type=custom_format
=== 500 from the API)Based on the API doc:
I would expect a buffer
Can you add a custom type and describe what we can use, and what to expect?
Thx 🙏
The text was updated successfully, but these errors were encountered: