@@ -20,6 +20,13 @@ import { FS, type FILE_SERVER_TARGET_TYPE } from './FileServerTarget';
2020const RELEASE_VERSION_ENDPOINT = '/session_version' ;
2121const FILE_ENDPOINT = '/file' ;
2222
23+ function getShortTTLHeadersIfNeeded ( ) : Record < string , string > {
24+ if ( window . sessionFeatureFlags ?. fsTTL30s ) {
25+ return { 'X-FS-TTL' : '30' } ;
26+ }
27+ return { } ;
28+ }
29+
2330/**
2431 * Upload a file to the file server v2 using the onion v4 encoding
2532 * @param fileContent the data to send
@@ -48,7 +55,7 @@ export const uploadFileToFsWithOnionV4 = async (
4855 endpoint : FILE_ENDPOINT ,
4956 method : 'POST' ,
5057 timeoutMs : 30 * DURATION . SECONDS , // longer time for file upload
51- headers : window . sessionFeatureFlags . fsTTL30s ? { 'X-FS-TTL' : '30' } : { } ,
58+ headers : getShortTTLHeadersIfNeeded ( ) ,
5259 } ) ;
5360
5461 if ( ! batchGlobalIsSuccess ( result ) ) {
@@ -203,20 +210,16 @@ export const extendFileExpiry = async (fileId: string, fsTarget: FILE_SERVER_TAR
203210
204211 const method = 'POST' ;
205212 const endpoint = `/file/${ fileId } /extend` ;
206- const headers : Record < string , string > = window . sessionFeatureFlags . fsTTL30s
207- ? { 'X-FS-TTL' : '30' }
208- : { } ;
209- const params = {
213+
214+ const result = await OnionSending . sendJsonViaOnionV4ToFileServer ( {
210215 abortSignal : new AbortController ( ) . signal ,
211216 endpoint,
212217 method,
213218 stringifiedBody : null ,
214- headers,
219+ headers : getShortTTLHeadersIfNeeded ( ) ,
215220 timeoutMs : 10 * DURATION . SECONDS ,
216221 target : fsTarget ,
217- } ;
218-
219- const result = await OnionSending . sendJsonViaOnionV4ToFileServer ( params ) ;
222+ } ) ;
220223
221224 if ( ! batchGlobalIsSuccess ( result ) ) {
222225 return null ;
0 commit comments