-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: Add large file upload #347
base: main
Are you sure you want to change the base?
Conversation
e1f72ed
to
b374a1c
Compare
* @interface | ||
* Signature to represent the upload session response | ||
*/ | ||
export interface UploadSessionResponse extends Parsable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed. Its the same as the UploadSession
type
* @returns {Promise<UploadResult<T> | undefined>} - The result of the upload. | ||
* @throws {Error} If the maximum number of retries is reached. | ||
*/ | ||
private async uploadWithRetry(uploadSlice: UploadSlice<T>, maxTries = 3): Promise<UploadResult<T> | undefined> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method is private and unused. Any chance this is intentional?
* @throws {Error} If the request fails. | ||
*/ | ||
public async updateSession() { | ||
const requestInformation = new RequestInformation(HttpMethod.GET, this.Session.uploadUrl!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid bang operators, they lead to nasty bugs.
instead, validate the value, and throw an explicit error
* @param {number} ms - The number of milliseconds to sleep. | ||
* @returns {Promise<void>} A promise that resolves after the specified time. | ||
*/ | ||
private sleep(ms: number): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment about this method if the retry one gets deleted
private async readSection(stream: ReadableStream<Uint8Array>, start: number, end: number): Promise<ArrayBuffer> { | ||
const reader = stream.getReader(); | ||
let bytesRead = 0; | ||
const chunks: Uint8Array[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as I understand this implementation, we're reading all the file at once and putting it all in memory. And this every time we upload a chunk. This is going to cause significant IOPS and memory pressure.
feat: Add large file upload
Resolve #7