MCPcopy Create free account
hub / github.com/codecombat/codecombat / uploadGenericPortrait

Method uploadGenericPortrait

app/models/ThangType.js:434–446  ·  view source on GitHub ↗
(callback, src)

Source from the content-addressed store, hash-verified

432 }
433
434 uploadGenericPortrait (callback, src) {
435 if (src == null) { src = this.getPortraitSource() }
436 if (!src || !_.string.startsWith(src, 'data:')) { return (typeof callback === 'function' ? callback() : undefined) }
437 src = src.replace('data:image/png;base64,', '').replace(/\ /g, '+') // eslint-disable-line no-useless-escape
438 const body = {
439 filename: 'portrait.png',
440 mimetype: 'image/png',
441 path: `db/thang.type/${this.get('original')}`,
442 b64png: src,
443 force: 'true',
444 }
445 return $.ajax('/file', { type: 'POST', data: body, success: callback || this.onFileUploaded })
446 }
447
448 onFileUploaded () {
449 return console.log('Image uploaded')

Callers 1

saveNewThangTypeMethod · 0.80

Calls 2

getPortraitSourceMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected