Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

381
Views
Envío de un archivo local como 'Archivo' en la solicitud posterior a través de NodeJs

Estoy tratando de llamar a esta API usando nodejs - https://developer.zebra.com/apis/sendfiletoprinter-model#/SendFileToPrinter/SendFiletoPrinter

Acepta un archivo zpl_file como una cadena (binario) que dice en la documentación.

Tengo un archivo zpl almacenado localmente y quiero adjuntarlo a mi solicitud de publicación usando el código NodeJs.

Este es el código que tengo hasta ahora, pero no puedo hacerlo funcionar. Cualquier ayuda en esto sería muy apreciada. ¡Gracias!

 exports.PrintUsingExampleCode = async function(payload) { let url = "https://api.zebra.com/v2/devices/printers/send"; let apikey = "<apikey>"; let tenant = "<tenant>"; let sn = "<printerSN>"; let filepath = 'C:\\ZPL\\HelloWorld.zpl' var req = require('request'); var fs = require('fs'); var fileToSend = fs.readFile('C:\\ZPL\\HelloWorld.txt'); req.post({ url: url, form: { sn: sn, tenant: tenant, apikey: apikey, zpl_file : fileToSend }, headers: { 'sn': sn, 'apikey' : apikey, 'tenant' : tenant }, method: 'POST' }, function (e, r, body) { console.log(body); }); };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

pase el archivo como una secuencia legible y un número de serie en la parte del formulario, y apiKey y arrendatario como encabezados:

 let url = "https://api.zebra.com/v2/devices/printers/send"; let apikey = "<apikey>"; let tenant = "<tenant>"; let sn = "<printerSN>"; let filepath = 'C:\\ZPL\\HelloWorld.zpl' var req = require('request'); var fs = require('fs'); var fileToSend = fs.createReadStream(filepath); req.post({ url: url, formData: { sn: sn, zpl_file: fileToSend }, headers: { 'apikey': apikey, 'tenant': tenant }, method: 'POST' }, function(e, r, body) { console.log(body); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!