{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Class: FileManager"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/readme"},"children":["PERS SDK - v2.3.26"]}," / ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/modules"},"children":["Exports"]}," / FileManager"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"class-filemanager","__idx":0},"children":["Class: FileManager"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["File Manager - Clean, high-level interface for file operations"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Provides a comprehensive API for file management including secure file uploads,"," ","download URLs, media optimization, and cloud storage integration. Handles file"," ","operations for various entity types including tokens, campaigns, businesses,"," ","and user profiles with automatic security and optimization features."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Get signed URL for uploading a campaign image\nconst uploadUrl = await sdk.files.getSignedPutUrl(\n  'campaign-123',\n  'campaign',\n  'jpg'\n);\n\n// Upload file using the signed URL\nconst file = document.getElementById('fileInput').files[0];\nconst response = await fetch(uploadUrl, {\n  method: 'PUT',\n  body: file,\n  headers: { 'Content-Type': file.type }\n});\n\nconsole.log('File uploaded successfully:', response.ok);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Get secure download URL\nconst downloadUrl = await sdk.files.getSignedGetUrl(\n  'token-456',\n  'token',\n  3600  // 1 hour expiry\n);\n\n// Get optimized thumbnail\nconst thumbnail = await sdk.files.optimizeMedia(\n  downloadUrl,\n  300,  // width\n  300   // height\n);\n\nconsole.log('Thumbnail URL:', thumbnail);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Use flexible signed URL API\nconst customUrl = await sdk.files.getSignedUrl({\n  operation: 'GET',\n  entityId: 'business-789',\n  entityType: 'business',\n  expireSeconds: 7200,\n  contentType: 'image/png'\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"table-of-contents","__idx":1},"children":["Table of contents"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"constructors","__idx":2},"children":["Constructors"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager#constructor"},"children":["constructor"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"methods","__idx":3},"children":["Methods"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager#getsignedputurl"},"children":["getSignedPutUrl"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager#getsignedgeturl"},"children":["getSignedGetUrl"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager#getsignedurl"},"children":["getSignedUrl"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager#optimizemedia"},"children":["optimizeMedia"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager#getfileservice"},"children":["getFileService"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"constructors-1","__idx":4},"children":["Constructors"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"constructor","__idx":5},"children":["constructor"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["• ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["new FileManager"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apiClient"]},"): ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FileManager"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters","__idx":6},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apiClient"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/persapiclient"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PersApiClient"]}]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns","__idx":7},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/filemanager"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FileManager"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in","__idx":8},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/file-manager.ts#L74"},"children":["managers/file-manager.ts:74"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"methods-1","__idx":9},"children":["Methods"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"getsignedputurl","__idx":10},"children":["getSignedPutUrl"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["getSignedPutUrl"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityId"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityType"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["fileExtension"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get signed URL for file upload"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Generates a secure, time-limited URL for uploading files to cloud storage."," ","The URL provides direct upload access while maintaining security and"," ","associating files with specific entities in the loyalty system."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-1","__idx":11},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Unique identifier of the entity to associate the file with"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FileUploadEntityType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Type of entity ('token', 'campaign', 'business', 'user', etc.)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["fileExtension"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["File extension without dot (e.g., 'jpg', 'png', 'pdf')"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-1","__idx":12},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Promise resolving to signed upload URL"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Throws"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When entity not found or upload not authorized"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"try {\n  // Get signed upload URL for campaign banner\n  const uploadUrl = await sdk.files.getSignedPutUrl(\n    'summer-campaign-2024',\n    'campaign',\n    'png'\n  );\n  \n  console.log('Upload URL generated:', uploadUrl);\n  \n  // Upload file from input element\n  const fileInput = document.getElementById('campaignBanner');\n  const file = fileInput.files[0];\n  \n  if (file) {\n    const uploadResponse = await fetch(uploadUrl, {\n      method: 'PUT',\n      body: file,\n      headers: {\n        'Content-Type': file.type\n      }\n    });\n    \n    if (uploadResponse.ok) {\n      console.log('Campaign banner uploaded successfully');\n    } else {\n      console.log('Upload failed:', uploadResponse.status);\n    }\n  }\n  \n} catch (error) {\n  console.log('Upload URL generation failed:', error.message);\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Upload logo for loyalty token\nconst tokenLogoUrl = await sdk.files.getSignedPutUrl(\n  'loyalty-points-token',\n  'token',\n  'svg'\n);\n\n// Upload SVG file\nconst svgFile = new File([svgContent], 'token-logo.svg', { type: 'image/svg+xml' });\nawait fetch(tokenLogoUrl, {\n  method: 'PUT',\n  body: svgFile,\n  headers: { 'Content-Type': 'image/svg+xml' }\n});\n\nconsole.log('Token logo uploaded');\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Upload business profile image\nconst businessImageUrl = await sdk.files.getSignedPutUrl(\n  'partner-hotel-123',\n  'business',\n  'jpg'\n);\n\n// Handle file upload with progress tracking\nconst file = selectedFile;\nconst xhr = new XMLHttpRequest();\n\nxhr.upload.addEventListener('progress', (e) => {\n  if (e.lengthComputable) {\n    const percentComplete = (e.loaded / e.total) * 100;\n    console.log(`Upload progress: ${percentComplete}%`);\n  }\n});\n\nxhr.open('PUT', businessImageUrl);\nxhr.send(file);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-1","__idx":13},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/file-manager.ts#L173"},"children":["managers/file-manager.ts:173"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"getsignedgeturl","__idx":14},"children":["getSignedGetUrl"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["getSignedGetUrl"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityId"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityType"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expireSeconds?"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get signed URL for file access"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Generates a secure, time-limited URL for accessing/downloading files from"," ","cloud storage. URLs automatically expire for security and can be used"," ","directly in image tags, download links, or API responses."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-2","__idx":15},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityId"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Unique identifier of the entity the file is associated with"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["entityType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FileUploadEntityType"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Type of entity ('token', 'campaign', 'business', 'user', etc.)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expireSeconds?"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["number"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Optional expiration time in seconds (default: 1 hour)"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-2","__idx":16},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Promise resolving to signed access URL"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Throws"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When entity or file not found or access denied"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"try {\n  // Get URL for displaying token logo\n  const logoUrl = await sdk.files.getSignedGetUrl(\n    'vip-status-token',\n    'token',\n    3600  // 1 hour expiry\n  );\n  \n  // Use in image element\n  const img = document.createElement('img');\n  img.src = logoUrl;\n  img.alt = 'VIP Status Token';\n  img.style.width = '64px';\n  img.style.height = '64px';\n  \n  document.getElementById('tokenContainer').appendChild(img);\n  \n  console.log('Token logo displayed');\n  \n} catch (error) {\n  console.log('Failed to load token logo:', error.message);\n  // Show fallback image\n  img.src = '/images/default-token.png';\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Get download URL for campaign assets\nconst downloadUrl = await sdk.files.getSignedGetUrl(\n  'holiday-campaign',\n  'campaign',\n  7200  // 2 hours for download\n);\n\n// Create download link\nconst link = document.createElement('a');\nlink.href = downloadUrl;\nlink.download = 'holiday-campaign-assets.zip';\nlink.textContent = 'Download Campaign Assets';\n\ndocument.body.appendChild(link);\n\n// Or trigger immediate download\nlink.click();\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Display business gallery images\nconst businessImages = ['image1', 'image2', 'image3'];\nconst gallery = document.getElementById('businessGallery');\n\nfor (const imageId of businessImages) {\n  try {\n    const imageUrl = await sdk.files.getSignedGetUrl(\n      `business-gallery-${imageId}`,\n      'business',\n      1800  // 30 minutes\n    );\n    \n    const img = document.createElement('img');\n    img.src = imageUrl;\n    img.className = 'gallery-image';\n    img.loading = 'lazy';\n    \n    gallery.appendChild(img);\n    \n  } catch (error) {\n    console.log(`Failed to load image ${imageId}:`, error.message);\n  }\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-2","__idx":17},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/file-manager.ts#L270"},"children":["managers/file-manager.ts:270"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"getsignedurl","__idx":18},"children":["getSignedUrl"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["getSignedUrl"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["request"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get signed URL for any file operation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Flexible method for generating signed URLs with custom parameters for"," ","various file operations including uploads, downloads, and deletions."," ","Provides fine-grained control over URL generation and file access permissions."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-3","__idx":19},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["request"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/interfaces/signedurlrequest"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SignedUrlRequest"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Signed URL request configuration"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-3","__idx":20},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Promise resolving to signed URL"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Throws"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When request parameters are invalid or access denied"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Create upload URL with specific content type and metadata\nconst advancedUploadUrl = await sdk.files.getSignedUrl({\n  operation: 'PUT',\n  entityId: 'premium-nft-123',\n  entityType: 'token',\n  fileExtension: 'png',\n  contentType: 'image/png',\n  expireSeconds: 300,  // 5 minutes for security\n  metadata: {\n    creator: 'artist-456',\n    collection: 'premium-series',\n    rarity: 'legendary'\n  }\n});\n\nconsole.log('Advanced upload URL created:', advancedUploadUrl);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Create very short-lived URL for sensitive document\nconst secureUrl = await sdk.files.getSignedUrl({\n  operation: 'GET',\n  entityId: 'compliance-document-789',\n  entityType: 'business',\n  expireSeconds: 60,  // 1 minute only\n  accessLevel: 'admin-only'\n});\n\n// Use immediately\nwindow.open(secureUrl, '_blank');\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Generate multiple URLs for batch file operations\nconst fileOperations = [\n  { operation: 'GET', entityId: 'doc1', entityType: 'campaign' },\n  { operation: 'GET', entityId: 'doc2', entityType: 'campaign' },\n  { operation: 'PUT', entityId: 'doc3', entityType: 'campaign', fileExtension: 'pdf' }\n];\n\nconst urls = await Promise.all(\n  fileOperations.map(op => sdk.files.getSignedUrl(op))\n);\n\nconsole.log('Generated batch URLs:', urls);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-3","__idx":21},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/file-manager.ts#L340"},"children":["managers/file-manager.ts:340"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"optimizemedia","__idx":22},"children":["optimizeMedia"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["optimizeMedia"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["url"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["width?"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["height?"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Optimize media file"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Creates optimized versions of media files with automatic resizing, format"," ","conversion, and compression. Perfect for generating thumbnails, responsive"," ","images, and bandwidth-optimized content while maintaining visual quality."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-4","__idx":23},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"left","data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["url"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Original file URL (can be signed or public URL)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["width?"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["number"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Optional target width in pixels"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["height?"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["number"]}]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"left"},"children":["Optional target height in pixels"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-4","__idx":24},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Promise"]},"<",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},">"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Promise resolving to optimized file URL"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Throws"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When optimization fails or source file is invalid"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Get original campaign banner URL\nconst originalUrl = await sdk.files.getSignedGetUrl('campaign-123', 'campaign');\n\n// Generate multiple optimized sizes\nconst thumbnail = await sdk.files.optimizeMedia(originalUrl, 150, 150);\nconst medium = await sdk.files.optimizeMedia(originalUrl, 400, 300);\nconst large = await sdk.files.optimizeMedia(originalUrl, 800, 600);\n\n// Use in responsive image setup\nconst img = document.createElement('img');\nimg.src = medium;  // Default size\nimg.srcset = `\n  ${thumbnail} 150w,\n  ${medium} 400w,\n  ${large} 800w\n`;\nimg.sizes = '(max-width: 400px) 150px, (max-width: 800px) 400px, 800px';\n\nconsole.log('Responsive image configured');\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Get user profile image and create avatars\nconst profileUrl = await sdk.files.getSignedGetUrl('user-456', 'user');\n\n// Generate different avatar sizes\nconst smallAvatar = await sdk.files.optimizeMedia(profileUrl, 32, 32);   // Nav bar\nconst mediumAvatar = await sdk.files.optimizeMedia(profileUrl, 64, 64);  // Comments\nconst largeAvatar = await sdk.files.optimizeMedia(profileUrl, 128, 128); // Profile page\n\n// Cache avatar URLs\nconst avatars = {\n  small: smallAvatar,\n  medium: mediumAvatar,\n  large: largeAvatar\n};\n\nlocalStorage.setItem('userAvatars', JSON.stringify(avatars));\nconsole.log('User avatars generated and cached');\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Generate thumbnails for business product gallery\nconst productImages = await getBusinessProductImages('business-789');\nconst thumbnails = [];\n\nfor (const productImage of productImages) {\n  try {\n    const originalUrl = await sdk.files.getSignedGetUrl(\n      productImage.id, \n      'business',\n      3600\n    );\n    \n    const thumbnail = await sdk.files.optimizeMedia(originalUrl, 200, 200);\n    \n    thumbnails.push({\n      id: productImage.id,\n      original: originalUrl,\n      thumbnail: thumbnail,\n      title: productImage.title\n    });\n    \n  } catch (error) {\n    console.log(`Failed to optimize ${productImage.id}:`, error.message);\n  }\n}\n\nconsole.log(`Generated ${thumbnails.length} product thumbnails`);\n\n// Display thumbnail gallery\nthumbnails.forEach(item => {\n  const img = document.createElement('img');\n  img.src = item.thumbnail;\n  img.alt = item.title;\n  img.onclick = () => showLightbox(item.original);\n  gallery.appendChild(img);\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"// Optimize with automatic format selection\nconst tokenIcon = await sdk.files.getSignedGetUrl('token-123', 'token');\n\n// System automatically chooses best format (WebP, AVIF, etc.)\nconst optimizedIcon = await sdk.files.optimizeMedia(tokenIcon, 48, 48);\n\nconsole.log('Optimized token icon (auto format):', optimizedIcon);\n\n// Use in token display\ndocument.querySelector('.token-icon').src = optimizedIcon;\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-4","__idx":25},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/file-manager.ts#L455"},"children":["managers/file-manager.ts:455"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"getfileservice","__idx":26},"children":["getFileService"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["▸ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["getFileService"]},"(): ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/fileservice"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FileService"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get the full file service for advanced operations"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Provides access to the complete FileService instance for advanced file"," ","operations, batch processing, storage analytics, and operations not"," ","covered by the high-level manager methods."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-5","__idx":27},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/sdk-reference/classes/fileservice"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FileService"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["FileService instance with full API access"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Example"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"const fileService = sdk.files.getFileService();\n\n// Access storage analytics\nconst storageStats = await fileService.getStorageAnalytics();\nconsole.log('Storage usage:', storageStats.totalSize);\n\n// Access batch file operations\nconst batchResult = await fileService.batchDeleteFiles(['file1', 'file2', 'file3']);\n\n// Access file metadata management\nconst metadata = await fileService.getFileMetadata('entity-123', 'campaign');\n\n// Access advanced optimization options\nconst advancedOptimization = await fileService.optimizeMediaAdvanced(url, {\n  width: 400,\n  height: 300,\n  quality: 85,\n  format: 'webp',\n  progressive: true,\n  watermark: 'brand-logo'\n});\n\n// Access file upload monitoring\nconst uploadProgress = fileService.monitorUploadProgress('upload-session-123');\nuploadProgress.on('progress', (percent) => {\n  console.log(`Upload: ${percent}%`);\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"defined-in-5","__idx":28},"children":["Defined in"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/eXplorins/PERS-sdks/blob/main/packages/pers-sdk/packages/pers-sdk/src/managers/file-manager.ts#L499"},"children":["managers/file-manager.ts:499"]}]}]},"headings":[{"value":"Class: FileManager","id":"class-filemanager","depth":1},{"value":"Table of contents","id":"table-of-contents","depth":2},{"value":"Constructors","id":"constructors","depth":3},{"value":"Methods","id":"methods","depth":3},{"value":"Constructors","id":"constructors-1","depth":2},{"value":"constructor","id":"constructor","depth":3},{"value":"Parameters","id":"parameters","depth":4},{"value":"Returns","id":"returns","depth":4},{"value":"Defined in","id":"defined-in","depth":4},{"value":"Methods","id":"methods-1","depth":2},{"value":"getSignedPutUrl","id":"getsignedputurl","depth":3},{"value":"Parameters","id":"parameters-1","depth":4},{"value":"Returns","id":"returns-1","depth":4},{"value":"Defined in","id":"defined-in-1","depth":4},{"value":"getSignedGetUrl","id":"getsignedgeturl","depth":3},{"value":"Parameters","id":"parameters-2","depth":4},{"value":"Returns","id":"returns-2","depth":4},{"value":"Defined in","id":"defined-in-2","depth":4},{"value":"getSignedUrl","id":"getsignedurl","depth":3},{"value":"Parameters","id":"parameters-3","depth":4},{"value":"Returns","id":"returns-3","depth":4},{"value":"Defined in","id":"defined-in-3","depth":4},{"value":"optimizeMedia","id":"optimizemedia","depth":3},{"value":"Parameters","id":"parameters-4","depth":4},{"value":"Returns","id":"returns-4","depth":4},{"value":"Defined in","id":"defined-in-4","depth":4},{"value":"getFileService","id":"getfileservice","depth":3},{"value":"Returns","id":"returns-5","depth":4},{"value":"Defined in","id":"defined-in-5","depth":4}],"frontmatter":{"seo":{"title":"Class: FileManager"}},"lastModified":"2026-08-21T18:40:55.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/sdk-reference/classes/filemanager","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}