Thanks! It definitely is one of the best plugins out there!

The only thing is that it is probably quite a bit of work to configure this workflow when i’m passing a variety of up to 120 files into the zip, while every file is a variable (to be included or not) depending on certain user characteristics.

I’m now actually trying to understand if i can integrate parts of that functionality into this one script via promises. But i’m pretty far out of my comfortzone creating and reading javascript :slight_smile:


function getSignedUrl(originalUrl) {
    return new Promise(async (resolve, reject) => {
      try {
        let signedUrl = originalUrl;

        // Ensure the URL starts with http/https.
        if (!signedUrl.startsWith("http")) {
          signedUrl = "https:" + signedUrl;
        }

        // Attempt HEAD request with the Bearer token.
        let response;
        try {
          response = await axios.head(signedUrl, {
            maxRedirects: 0,
            validateStatus: (status) =>
              status === 302 || (status >= 200 && status < 300),
            headers: { Authorization: `Bearer ${bubbleApiKey}` },
          });
        } catch (authError) {
          // If the authorized HEAD fails, try again without any Authorization header.
          try {
            response = await axios.head(signedUrl, {
              maxRedirects: 0,
              validateStatus: (status) =>
                status === 302 || (status >= 200 && status < 300),
            });
          } catch (unauthError) {
            return reject(unauthError);
          }
        }

        // If we get a redirect location, that’s our signed/redirected URL.
        if (response && response.headers && response.headers.location) {
          resolve(response.headers.location);
        } else {
          // Otherwise, the URL itself is valid for direct GET.
          resolve(signedUrl);
        }
      } catch (err) {
        reject(err);
      }
    });
  }

but i’ts a bit like i’m blindfolded throwing some darts around hoping to hit something :slight_smile: