Skip to content

Using form-data with typed-rest-client #410

@mmajcica

Description

@mmajcica

Dear,

I'm planning to upload a file base on multipart/form-data specs. I found your library and I'm curious how to use it in my typescript application. I'm using typed-rest-client for all of my http calls.
I suppose I could leverage the uploadStream method from the rest client in order to integrate with form-data.

    public async uploadStream<T>(verb: string,
        requestUrl: string,
        stream: NodeJS.ReadableStream,
        options?: IRequestOptions): Promise<IRestResponse<T>> {

        let url: string = util.getUrl(requestUrl, this._baseUrl);
        let headers: ifm.IHeaders = this._headersFromOptions(options, true);

        let res: httpm.HttpClientResponse = await this.client.sendStream(verb, url, stream, headers);
        return this._processResponse<T>(res, options);
    }

Is there an example on how to achieve something like this?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions