Skip to content

pusher.file uploads junk in version 3.0.0 #49

@davidnewcomb

Description

@davidnewcomb

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions