Skip to content

Commit

Permalink
General: Fix an issue in Chrome when uploading files (#9766)
Browse files Browse the repository at this point in the history
  • Loading branch information
eceeeren authored Nov 14, 2024
1 parent 050b096 commit d266ee6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/main/webapp/app/lecture/attachment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ export class AttachmentService {
copy.lecture.posts = undefined;
}

/** Ngsw-worker is bypassed temporarily to fix Chromium file upload issue
* See: https://issues.chromium.org/issues/374550348
**/
return this.http
.post<Attachment>(this.resourceUrl, this.createFormData(copy, file), { observe: 'response' })
.post<Attachment>(this.resourceUrl, this.createFormData(copy, file), { headers: { 'ngsw-bypass': 'true' }, observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertAttachmentResponseDatesFromServer(res)));
}

Expand All @@ -51,8 +54,11 @@ export class AttachmentService {
const options = createRequestOption(req);
const copy = this.convertAttachmentDatesFromClient(attachment);

/** Ngsw-worker is bypassed temporarily to fix Chromium file upload issue
* See: https://issues.chromium.org/issues/374550348
**/
return this.http
.put<Attachment>(this.resourceUrl + '/' + attachmentId, this.createFormData(copy, file), { params: options, observe: 'response' })
.put<Attachment>(this.resourceUrl + '/' + attachmentId, this.createFormData(copy, file), { headers: { 'ngsw-bypass': 'true' }, params: options, observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertAttachmentResponseDatesFromServer(res)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,27 @@ export class AttachmentUnitService {
}

create(formData: FormData, lectureId: number): Observable<EntityResponseType> {
/** Ngsw-worker is bypassed temporarily to fix Chromium file upload issue
* See: https://issues.chromium.org/issues/374550348
**/
return this.httpClient
.post<AttachmentUnit>(`${this.resourceURL}/lectures/${lectureId}/attachment-units?keepFilename=true`, formData, { observe: 'response' })
.post<AttachmentUnit>(`${this.resourceURL}/lectures/${lectureId}/attachment-units?keepFilename=true`, formData, {
headers: { 'ngsw-bypass': 'true' },
observe: 'response',
})
.pipe(map((res: EntityResponseType) => this.lectureUnitService.convertLectureUnitResponseDatesFromServer(res)));
}

update(lectureId: number, attachmentUnitId: number, formData: FormData, notificationText?: string): Observable<EntityResponseType> {
/** Ngsw-worker is bypassed temporarily to fix Chromium file upload issue
* See: https://issues.chromium.org/issues/374550348
**/
return this.httpClient
.put<AttachmentUnit>(
`${this.resourceURL}/lectures/${lectureId}/attachment-units/${attachmentUnitId}?keepFilename=true` +
(notificationText ? `&notificationText=${notificationText}` : ''),
formData,
{ observe: 'response' },
{ headers: { 'ngsw-bypass': 'true' }, observe: 'response' },
)
.pipe(map((res: EntityResponseType) => this.lectureUnitService.convertLectureUnitResponseDatesFromServer(res)));
}
Expand Down

0 comments on commit d266ee6

Please sign in to comment.