Skip to content

Commit 4f13e0f

Browse files
authored
* feat(headers): add headers support to metadata and storeUr
* feat(headers): add headers to metadata and storeUrl * feat(headers): add headers param to storeUrl * docs(headers): update store headers * test(pickerSchema): update picker optiosn schema - add custm source * refactor(prefetch): Fix import for cloneDeep * fix(request/http): udpate cancel token handling in node http requests
1 parent a304076 commit 4f13e0f

File tree

10 files changed

+302
-70
lines changed

10 files changed

+302
-70
lines changed

package-lock.json

Lines changed: 223 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/api/cloud.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,11 @@ export class CloudClient {
244244
});
245245
}
246246

247-
metadata(url: string) {
247+
metadata(url: string, headers?: {[key: string]: string}) {
248248
const payload: any = {
249249
apikey: this.session.apikey,
250250
url,
251+
headers,
251252
};
252253

253254
if (this.session.policy && this.session.signature) {

src/lib/api/prefetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Session, Security, Client } from './../client';
2121
import { PickerOptions } from './../picker';
2222
import { FsRequest } from '../request';
2323
import { cleanUpCallbacks } from './../utils';
24-
import cloneDeep from 'lodash.clonedeep';
24+
import * as cloneDeep from 'lodash.clonedeep';
2525

2626
// const debug = Debug('fs:prefetch');
2727

src/lib/api/store.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type StoreUrlParams = {
2929
token?: any;
3030
security?: Security;
3131
uploadTags?: UploadTags;
32+
headers?: {[key: string]: string},
3233
};
3334

3435
/**
@@ -48,6 +49,7 @@ export const storeURL = ({
4849
token,
4950
security,
5051
uploadTags,
52+
headers,
5153
}: StoreUrlParams): Promise<any> => {
5254
if (!url || typeof url !== 'string') {
5355
return Promise.reject(new FilestackError('url is required for storeURL'));
@@ -80,11 +82,20 @@ export const storeURL = ({
8082
options.cancelToken = cancelToken;
8183
}
8284

85+
let sources: any = [ url ];
86+
87+
if (headers) {
88+
sources = [{
89+
source: url,
90+
headers,
91+
}];
92+
}
93+
8394
return FsRequest.post(`${session.urls.processUrl}/process`, {
8495
apikey: session.apikey,
85-
sources: [ url ],
96+
sources,
8697
tasks: filelink.getTasks(),
87-
upload_tags: uploadTags ? uploadTags : undefined,
98+
upload_tags: uploadTags,
8899
}, options).then((res) => {
89100
if (res.data && res.data.handle) {
90101
if (res.data.upload_tags) {

0 commit comments

Comments
 (0)