TypeError uploading a playlist cover image
See original GitHub issueI get the following error when I try to upload a playlist cover image. Authentication is working and the scope contains "playlist-read-private", "playlist-modify-private", "playlist-modify-public", "ugc-image-upload"
.
TypeError: "string" must be a string, Buffer, or ArrayBuffer
at Function.byteLength (buffer.js:481:11)
at Request._end (/Users/user/Desktop/project/node_modules/superagent/lib/node/index.js:804:84)
at Request.end (/Users/user/Desktop/project/node_modules/superagent/lib/node/index.js:777:15)
at Object.HttpManager._makeRequest (/Users/user/Desktop/project/node_modules/spotify-web-api-node/src/http-manager.js:85:7)
at HttpManager.put (/Users/user/Desktop/project/node_modules/spotify-web-api-node/src/http-manager.js:146:15)
at /Users/user/Desktop/project/node_modules/spotify-web-api-node/src/base-request.js:92:5
at new Promise (<anonymous>)
at Request.execute (/Users/user/Desktop/project/node_modules/spotify-web-api-node/src/base-request.js:91:10)
at SpotifyWebApi.uploadCustomPlaylistCoverImage (/Users/user/Desktop/project/node_modules/spotify-web-api-node/src/spotify-web-api.js:609:8)
at addCoverToSpotifyPlaylist (/Users/user/Desktop/project/scripts/main.js:131:6)
My code
spotifyApi.uploadCustomPlaylistCoverImage('191...9Ud', '/9j/4AAQSk...KACgAoAKAP//Z')
.then(
(data) => { ... },
(error) => { ... }
);
System
OS: macOS 10.13.6
Node Version: v8.12.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How do I upload a custom playlist cover image with Spotify API
I'm downloading pictures from Spotify before uploading them to new playlist. // Legacy code not optimized used to gather Spotify cover img ...
Read more >Can't Upload a new Image to my Spotify Playlist an...
I am not able to change the cover of a new made playlist anymore. Since the last update it doesn't work anymore. I...
Read more >Solved: Re: TypeError: Error #1085: Actionscript 3 videopl... - Adobe ...
I have a videoplayer that loads video from xml and players it. The code works well when loading the xml. But because I...
Read more >AudioPlayer Interface Reference | Alexa Skills Kit
For version 1.0 of a music skill that doesn't yet support playlists and ... AudioPlayer with custom background image, title, subtitle, and album...
Read more >How to Fix the 'Preview Could Not Be Loaded' Error - Elementor
For example in the image below, it says “Preview Debug”. ... the front-end it can cause loading issues, These URLs can be checked...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
same here!
edit: I ended up implementing my own method for now:
Apparently the underlying superagent module (used here) does not output much information about this error, this is already part of another PR (see: https://github.com/visionmedia/superagent/issues/1482). This is why the error message is kinda confusing.
tl;dr:
See the diff in my personal repository on how to fix the error: https://github.com/dersimn/spotify-web-api-node/commit/57f14da2aea46bb4ea6dc6fde16c8c41785ef7be
long:
Function
spotifyApi.uploadCustomPlaylistCoverImage(id, base64)
passes the base64 (typeof =string
) toWebApiRequest.withBodyParameters(base64)
(here)WebApiRequest.withBodyParameters(base64)
(here) itself is a call toWebApiRequest._assigner('bodyParameters')(base64)
which destructs the String by this for-loop into an object looking like:typeof this.bodyParameters
=>object
ends up in HttpManager (which utilises superagent) and is passed tosuperagent.send(base64AsFuckedUpObject)
and causes the error whensuperagent.end()
is invoked here.