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

posting multipart form data with oauth #353

Open
Tekrajs opened this issue May 31, 2020 · 3 comments
Open

posting multipart form data with oauth #353

Tekrajs opened this issue May 31, 2020 · 3 comments

Comments

@Tekrajs
Copy link

Tekrajs commented May 31, 2020

Hello,
I am trying to upload image to etsy with this package. I did the following for performing the operation.

    ` public async post(path: string, params: any, content: any, type: any) {
    var url: string;
    url = this.buildUrl(path, params);

    if (!this.authToken || !this.authSecret)
        throw new Error("Invalid or missing Token or Secret");

    console.log(type)
    let response: any = await new Promise((resolve, reject) => {
        return this.oauth.post(url, this.authToken, this.authSecret, content, type || false, function (err: any, data: any, response: any) {
            if (err) {
                return reject(err);
            }

            return resolve({ res: response, data: data });
        });
    });

    if (!response)
        throw new Error("Invalid response for request performed, please try again");

    return await this.handleResponse(response.res, response.data);

};`

the content passed to oauth.post is
{ name: __dirname + '/images/article-3.png', mime: 'image/jpeg', postname: 'article-3' }

Since the content type of content is not string and in library i saw this code

if ( typeof post_body != "string" && !Buffer.isBuffer(post_body) ) { post_content_type= "application/x-www-form-urlencoded" extra_params= post_body; post_body= null; }

my post content type is always application/x-www-form-urlencoded and i always get
oauth_problem=signature_invalid
problem.
Can any one please provide me a sample code to upload a file with this oauth library to any api. Thanks.

@jmgunter
Copy link

@Tekrajs did you figure this out? I'm trying to do the same thing.

@oguzhanbulut
Copy link

I'm dealing with the same problem.

@patrickkmatias
Copy link

could somebody do it three years later?

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

4 participants