Restart input stream on retried request

This commit is contained in:
Fedor Indutny 2024-07-11 12:04:48 -07:00 committed by GitHub
parent 328117cecf
commit 273e1ccb15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -169,7 +169,7 @@ type PromiseAjaxOptionsType = {
basicAuth?: string;
certificateAuthority?: string;
contentType?: string;
data?: Uint8Array | Readable | string;
data?: Uint8Array | (() => Readable) | string;
disableRetries?: boolean;
disableSessionResumption?: boolean;
headers?: HeaderListType;
@ -299,7 +299,7 @@ async function getFetchOptions(
const fetchOptions = {
method: options.type,
body: options.data,
body: typeof options.data === 'function' ? options.data() : options.data,
headers: {
'User-Agent': getUserAgent(options.version),
'X-Signal-Agent': 'OWD',
@ -1303,7 +1303,7 @@ export type WebAPIType = {
elements: VerifyServiceIdRequestType
) => Promise<VerifyServiceIdResponseType>;
putEncryptedAttachment: (
encryptedBin: Uint8Array | Readable,
encryptedBin: Uint8Array | (() => Readable),
uploadForm: AttachmentV3ResponseType
) => Promise<void>;
putProfile: (
@ -3530,7 +3530,7 @@ export function initialize({
}
async function putEncryptedAttachment(
encryptedBin: Uint8Array | Readable,
encryptedBin: Uint8Array | (() => Readable),
uploadForm: AttachmentV3ResponseType
) {
const { signedUploadLocation, headers } = uploadForm;

View file

@ -146,7 +146,7 @@ export async function uploadFile({
});
} else {
await server.putEncryptedAttachment(
createReadStream(absoluteCiphertextPath),
() => createReadStream(absoluteCiphertextPath),
uploadForm
);
}