Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

feat: Add large file upload #347

wants to merge 6 commits into from

Conversation

rkodev
Copy link
Contributor

@rkodev rkodev commented Feb 11, 2025

feat: Add large file upload

Resolve #7

@rkodev rkodev force-pushed the feat/large-file-upload branch from e1f72ed to b374a1c Compare February 14, 2025 03:01
@rkodev rkodev marked this pull request as ready for review February 21, 2025 06:17
@rkodev rkodev requested a review from a team as a code owner February 21, 2025 06:17
* @interface
* Signature to represent the upload session response
*/
export interface UploadSessionResponse extends Parsable {
Copy link
Member

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> {
Copy link
Member

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!);
Copy link
Member

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> {
Copy link
Member

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[] = [];
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for large file upload
3 participants