-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1362 from nickgros/SWC-7064e
- Loading branch information
Showing
17 changed files
with
2,487 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/synapse-react-client/src/synapse-queries/file/useSynapseMultipartUpload.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { SynapseClientError } from '@sage-bionetworks/synapse-client' | ||
import { FileUploadComplete } from '@sage-bionetworks/synapse-types' | ||
import { useMutation, UseMutationOptions } from '@tanstack/react-query' | ||
import { uploadFile } from '../../synapse-client/SynapseClient' | ||
import { useSynapseContext } from '../../utils/index' | ||
import { FileUploadArgs } from './FileUploadArgs' | ||
|
||
type UseSynapseMultipartUploadArgs = FileUploadArgs & { | ||
readonly storageLocationId: number | undefined | ||
} | ||
|
||
export function useSynapseMultipartUpload( | ||
options?: UseMutationOptions< | ||
FileUploadComplete, | ||
SynapseClientError, | ||
UseSynapseMultipartUploadArgs | ||
>, | ||
) { | ||
const { accessToken } = useSynapseContext() | ||
return useMutation({ | ||
...options, | ||
mutationFn: (args: UseSynapseMultipartUploadArgs) => { | ||
const { | ||
blob, | ||
fileName, | ||
storageLocationId, | ||
contentType, | ||
progressCallback, | ||
abortController, | ||
onMd5Computed, | ||
} = args | ||
|
||
return uploadFile( | ||
accessToken, | ||
fileName, | ||
blob, | ||
storageLocationId, | ||
contentType, | ||
progressCallback, | ||
undefined, | ||
onMd5Computed, | ||
abortController, | ||
) | ||
}, | ||
}) | ||
} |
Oops, something went wrong.