Skip to content

Commit

Permalink
no-cors
Browse files Browse the repository at this point in the history
  • Loading branch information
Blainegunn committed May 24, 2024
1 parent 13dc3ba commit e0a7f4f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions acrobat/blocks/acom-widget/acom-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ const uploadToAdobe = async (file, progressBarWrapper, progressBar) => {
// console.log(`PDF created successfully: ${metadataResult.asset_id}`);

// Step 5: Fetch Download URI
const downloadUriEndpoint = `${baseApiUrl}/${expiry}/assets/download_uri?asset_uri=${encodeURIComponent(assetUri)}&make_direct_storage_uri=true`;
// eslint-disable-next-line compat/compat
const downloadUriResponse = await fetch(downloadUriEndpoint, { mode: 'no-cors', headers: { Authorization: `Bearer ${accessToken}` } });
// const downloadUriEndpoint = `${baseApiUrl}/${expiry}/assets/download_uri?asset_uri=${encodeURIComponent(assetUri)}&make_direct_storage_uri=true`;
// // eslint-disable-next-line compat/compat
// const downloadUriResponse = await fetch(downloadUriEndpoint, { mode: 'no-cors', headers: { Authorization: `Bearer ${accessToken}` } });

if (!downloadUriResponse.ok) {
throw new Error(`Failed to fetch download URI: ${downloadUriResponse.statusText}`);
}
// if (!downloadUriResponse.ok) {
// throw new Error(`Failed to fetch download URI: ${downloadUriResponse.statusText}`);
// }

const downloadUriResult = await downloadUriResponse.json();
const downloadUri = downloadUriResult.uri;
Expand All @@ -242,6 +242,7 @@ const uploadToAdobe = async (file, progressBarWrapper, progressBar) => {
itemType: 'application/pdf',
};

console.log(`${baseApiUrl}/${expiry}/assets/download_uri?asset_uri=${encodeURIComponent(assetUri)}&make_direct_storage_uri=true`);
const encodedBlobUrl = encodeBlobUrl(blobUrlStructure);
const blobViewerUrl = `https://acrobat.adobe.com/blob/${encodedBlobUrl}?defaultRHPFeature=verb-quanda&x_api_client_location=chat_pdf&pdfNowAssetUri=${assetUri}#${downloadUri}`;
console.log('Blob URL:', blobViewerUrl);
Expand Down

0 comments on commit e0a7f4f

Please sign in to comment.