Skip to content

Commit

Permalink
feat(workflows): Add support for workflows (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholuj authored Sep 24, 2018
1 parent b6e73c0 commit ddeb93a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/api/upload/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export const complete = (etags: string, { config, file, params }: Context): Prom
/* istanbul ignore next */
const host = getHost(config.host) || getLocationURL(params.location_url);
const locationRegion = params.location_region;

const fields = {
apikey: config.apikey,
size: file.size,
Expand All @@ -178,6 +179,11 @@ export const complete = (etags: string, { config, file, params }: Context): Prom
parts: formatETags(etags),
...params,
};

if (config.workflowIds && config.workflowIds.length) {
fields['workflow_ids'] = JSON.stringify(config.workflowIds);
}

// Intelligent Ingestion
if (config.intelligent) {
fields.multipart = true;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/api/upload/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ export interface UploadOptions {
* Set the default intiial chunk size for Intelligent Ingestion. Defaults to 8MB on desktop and 1MB on mobile.
*/
intelligentChunkSize?: number;

/**
* Array with workflow ids
*/
workflowIds?: string[];
}

export interface FSProgressEvent {
Expand Down
16 changes: 16 additions & 0 deletions src/lib/api/upload/upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,22 @@ if (ENV.testEnv === 'unit') {
done();
});
});

it('should upload a file successfully with provided workflows ids', (done) => {
upload(session, smallFile, {
retry: 0,
mimetype: 'image/gif',
workflowIds: ['test', 'test1']
})
.then((res: any) => {
assert.ok(res.handle);
assert.ok(res.url);
done();
})
.catch((err: Error) => {
done(err);
});
});
});
});
}
1 change: 1 addition & 0 deletions src/lib/api/upload/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ export const upload = (
{ name: 'timeout', type: t.Integer },
{ name: 'intelligent', type: t.union([t.Boolean, t.enums.of('fallback')]) },
{ name: 'intelligentChunkSize', type: t.Number },
{ name: 'workflowIds', type: t.list(t.String) },
];
const allowedStoreOptions = [
{ name: 'location', type: t.enums.of('s3 gcs rackspace azure dropbox') },
Expand Down

0 comments on commit ddeb93a

Please sign in to comment.