Glitch Project İmage Upload

java

#1
const bkg = await loadImage("../photos/scard.png");

How can I add pictures / url directly to my Glitch project?

Error:
    (node:7045) UnhandledPromiseRejectionWarning: TypeError: createCanvas is not a function

at Object.module.exports.run (/app/komutlar/deneme.js:7:16)

at Client.module.exports.message (/app/events/message.js:25:9)

    at emitOne (events.js:121:20)

    at Client.emit (events.js:211:7)

    at MessageCreateHandler.handle (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)

    at WebSocketPacketManager.handle (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)

    at WebSocketConnection.onPacket (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)

    at WebSocketConnection.onMessage (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)

    at WebSocket.onMessage (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/event-target.js:120:16)

    at emitOne (events.js:116:13)

    at WebSocket.emit (events.js:211:7)

    at Receiver._receiver.onmessage (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/websocket.js:137:47)

    at Receiver.dataMessage (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/receiver.js:409:14)

    at Receiver.getData (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/receiver.js:347:12)

    at Receiver.startLoop (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/receiver.js:143:16)

    at Receiver.add (/rbd/pnpm-volume/aaec3d2d-aebb-4535-97bc-3451acb56ac6/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/receiver.js:117:10)

    at emitOne (events.js:116:13)

    at TLSSocket.emit (events.js:211:7)

    at addChunk (_stream_readable.js:263:12)

    at readableAddChunk (_stream_readable.js:250:11)

    at TLSSocket.Readable.push (_stream_readable.js:208:10)

    at TLSWrap.onread (net.js:601:20)

(node:7045) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

MOD EDIT: error formatting


#2

Hey @MeliL, for the time being getting images to your Glitch project’s file system is a little bit of a hassle; we have work in our backlog to improve this behavior, but I don’t have a timeline on when that work might be completed.

To get the behavior you want you’ll need to use your project’s console and download the image you’re interested in from there. Something like wget https://link-to-your-photo.com/scard.png will get the image into your project’s file system and from there you can use the rename feature to move to where you need it to be.

If the file is local you can drag and drop it on the Glitch window which will upload it to the asset drawer at the top of the filelist. Once it’s there you can click on it and select “Copy url” and then use wget to download it from that url to your project’s file system.

Please let us know if you need additional assistance, and I apologize for the inconvenience!


#3

exactly what to write to the console to download the picture


#4

Have you saved it to your assets drawer by dragging and dropping? Or do you have a link to the file somewhere in the web?

Also can you provide your project name?


#5

Project name: salty-airport

add to assets and gives an error when I link


#6

This is Error:
(node:871) UnhandledPromiseRejectionWarning: TypeError: createCanvas is not a function

at Object.module.exports.run (/app/komutlar/deneme.js:7:16)


#7

Help me please help add to assets and gives an error when I link


#8

Hi @MeliL just guessing form the contents of your file, but it looks like you’ve got the process for getting images into your project figured out (I say that because I see images in your project’s file list) - is that correct?

I’m also not seeing the createCanvas error, so it looks like that part’s also working; is that correct?

Is so then it looks to me like perhaps you’re running into an issue with loadImage on https://glitch.com/edit/#!/salty-airport?path=komutlar/deneme.js:9:0. If that’s the case then I think you’re running into trouble because loadImage() requires a local image or stream. What you’re doing with the avatar at https://glitch.com/edit/#!/salty-airport?path=komutlar/deneme.js:13:0 should also work fine for loading the scard.png image.

If I’ve misinterpreted where you’re running into problems please let me know where you are running into trouble and we’ll see if we can help out.