Skip to content

node-fetch uploadListingImage 'Unrecognized file format' #1145

Answered by littlebee
littlebee asked this question in Q&A
Discussion options

You must be logged in to vote

I think I figured it out. I hadn't explicitly imported FormData and it looks like maybe Next.js implementation/polyfill doesn't support files? IDKFC

This code works:

import fs from "fs";
import path from "path";

import fetch from "node-fetch";
import FormData from "form-data";

const API_URL = "https://openapi.etsy.com/v3/application";

function etsyUploadListingImageUrl(shopId: number, listingId: number) {
  return `${API_URL}/shops/${shopId}/listings/${listingId}/images`;
}

export async function uploadListingImage(
  shopId: number,
  listingId: number,
  oauthToken: string,
  apiKey: string,
  rank: number,
  imageFilePath: string,
): Promise<any> {
  const url = etsyUploadListingIma…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by littlebee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant