Skip to content
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

pusher.file uploads junk in version 3.0.0 #49

Open
davidnewcomb opened this issue Aug 1, 2023 · 0 comments
Open

pusher.file uploads junk in version 3.0.0 #49

davidnewcomb opened this issue Aug 1, 2023 · 0 comments

Comments

@davidnewcomb
Copy link

davidnewcomb commented Aug 1, 2023

I'm trying to send a file using version 3.0.0 and it's uploading junk.
Do you get the same results?

import PushBullet from 'pushbullet'
import fs from 'fs'
import { API_KEY, DEVICE_NICKNAME } from './config.js'

console.log('Start')

let resp,obj
const pusher = new PushBullet(API_KEY)
resp = await pusher.devices()
obj = await resp.json()
let devices = obj.devices
let device = devices.find((d) => d.nickname === DEVICE_NICKNAME)
const destId = device.iden
console.log('Device Id:', destId)

resp = await pusher.file(destId, '1-jack.jpg', 'Pic of jack')
obj = await resp.json()
//console.log('File:',JSON.stringify(obj, null, 4))
let uploadedFile = obj.file_url
console.log('File url:' + uploadedFile)

resp = await fetch(uploadedFile)
//console.log('resp=', resp)
console.log('resp-len=', resp.headers.get('content-length'))
obj = await resp.text()
console.log('body=', obj)

Image file

root@docker:/dir# ls -l 
-rwxrwxrwx   1 root       root       1538023 Aug  1 00:11 1-jack.jpg

Results:

Start
Device Id: ujy8OAKQBl6sjCthOSFPQO
File url:https://dl3.pushbulletusercontent.com/abc.../1-jack.jpg
resp-len= 15
body= [object Object]

The file that has been uploaded just contains the string "[object Object]". I have checked this by downloading it in Firefox and curl. PushBullet app fails to show picture properly. Is there something obvious, I'm doing wrong? Do you get the same problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant