Comments (5)
Hi @dragoncodes, thank you for the report! Would it be possible for you to take my changes from #158, apply it to the code in your node_modules/gaxios
and check if it helped to solve your original problem with the publisher API?
The code in build/src/gaxios.js
(after TypeScript compilation) should be like this:
@@ -137,7 +152,9 @@
}
else if (typeof opts.data === 'object') {
opts.body = JSON.stringify(opts.data);
- opts.headers['Content-Type'] = 'application/json';
+ if (!Object.keys(opts.headers).some((key) => key.match(/^content-type$/i))) {
+ opts.headers['Content-Type'] = 'application/json';
+ }
}
else {
opts.body = opts.data;
If you confirm it fixes the problem for you, we'll release the updated version. If not, we'll keep debugging :)
Thank you!
from gaxios.
I tried to test the fix for the apk upload (Content-Type: application/vnd.android.package-archive), but another request can't go through because it's in application/x-www-form-urlencoded
, but the data is still being stringified.
This leads me to believe that a lot of users, including other libraries, have been relying on this behavior and changes may become "breaking".
To test out the full procedure in my case I added a reversed flag disableAutomaticHeaderResolution
:
if (this.isReadableStream(opts.data)
|| this.opts.disableAutomaticHeaderResolution) { // <- this bit
opts.body = opts.data;
} else if (typeof opts.data === 'object') { ... }
It seems like a dirty fix, but it can then be adopted faster and safer.
from gaxios.
Thanks @dragoncodes, I'm reverting my fix for now (#161). We'll figure out what to do here :)
from gaxios.
Any progress with this? I want to use this lib but I'm worried about this potentially causing problems.
from gaxios.
@dragoncodes I'm wondering if behavior might have changed since this issue was opened...
But you should be able to set a custom content-type
header as long as you're providing a string
or readable stream body. (Buffer
isn't actually a type accepted by the underlying node-fetch
library, or at least it's not documented that it does).
So, I think you can modify your code to something like this, and it would work:
const apk = fs.readFileSync(apkFilePath);
this.publisher.edits.apks.upload({
editId,
packageName,
media: {
mimeType: 'application/vnd.android.package-archive',
body: apk.toString()
}
}, (err, res) => {});
or,
const apk = fs.readFile(apkFilePath);
this.publisher.edits.apks.upload({
editId,
packageName,
media: {
mimeType: 'application/vnd.android.package-archive',
body: apk // <-- readable stream.
}
}, (err, res) => {});
@CodeWithOz this library should work for you 👍
I'm pretty sure the problem described here was either:
- missing documentation , or.
- a bug with the upstream
googleapis
library, which usesgaxios
.
from gaxios.
Related Issues (20)
- Your .repo-metadata.json file has a problem 🤒
- Your .repo-metadata.json file has a problem 🤒
- Ensuring compliance with SNI Extension requirement on remote host HOT 3
- Support proxy option instead of HTTP_PROXY env variable HOT 4
- Get request with one-item array param, will send the value inside instead the the array HOT 1
- Feature request: optional error throwing HOT 2
- 📦 pack and install: "before all" hook: pack and install for "should run the sample" failed HOT 4
- can i please for more docs about comparison with axios HOT 1
- Incorrect GaxiosError message type when request responseType "arrayBuffer" HOT 2
- Uncaught ReferenceError: process is not defined HOT 1
- content-type parsing is performed even if a `text` response type is explicitly requested, causing an unmanageable error HOT 3
- timeout - seconds or milliseconds HOT 1
- feat!: Use Native `cause` in `GaxiosError`
- Using googleapis for direct CSV downloads does not return CSV
- Typo on README.md
- feat: Updated `timeout` Implementation and Documentation HOT 1
- feat: Add `client_secret` to `defaultErrorRedactor` HOT 2
- Warning: a recent release failed HOT 1
- Warning: a recent release failed HOT 1
- Warning: a recent release failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gaxios.