AdobeDocs / cis-photoshop-api-docs

https://developer.adobe.com/photoshop/photoshop-api-docs/
https://developer.adobe.com/photoshop/photoshop-api-docs/
Apache License 2.0
16 stars 27 forks source link

Unable to upload the outputs - Access Is Forbidden #160

Open velara3 opened 8 months ago

velara3 commented 8 months ago

When I try to create a rendition and save it to S3 I am getting the following error:

{
  code: 403,
  details: [
    {
      name: 'https://s3.amazonaws.com/...',
      reason: 'Unable to upload the outputs'
    }
  ],
  title: 'Access Is Forbidden',
  type: 'AuthForbidden'
}
      // GENERATE A NEW TOKEN
      const authDetails: string = await this.generateIMSToken(clientIdAndApiKey, clientSecret);
      let authInfo = JSON.parse(authDetails);
      authToken = authInfo.access_token;

      // CREATE PS API OBJECT
      const client = await sdk.init(ims, clientIdAndApiKey, authToken);

      // GET SIGNED URL
      var signedPSDGetURL = await getSignedUrl(key, bucket);

      // CREATE SIGNED URL FOR SAVING THE OUTPUT
      var signedPutURL = await getSignedPutUrl(putKey, bucket);

      // CREATE DOCUMENT RENDITION
      var psdInputOptions = {
        href: signedPSDGetURL,
        storage: sdk.Storage.EXTERNAL
      }

      var psdOutputOptions = {
        href: signedPutURL,
        type: sdk.MimeType.PNG,
        storage: sdk.Storage.EXTERNAL,
        overwrite: true
      }

      const renditionResults = await client.createRendition(psdInputOptions, psdOutputOptions);
      console.log(renditionResults);

The results are:

Job {
  getJobStatus: [Function: bound __getJobStatus] AsyncFunction,
  url: 'https://image.adobe.io/pie/psdService/status/....',
  jobId: '...',
  outputs: [
    {
      input: 'https://s3.amazonaws.com/...',
      status: 'failed',
      created: '...',
      modified: '...',
      errors: [Object]
    }
  ],
  _links: {
    self: {
      href: 'https://image.adobe.io/pie/psdService/status/...'
    }
  }
}

I don't know what else I need to do

velara3 commented 8 months ago

So it was mentioned that maybe I need to use a signed Post URL? If so here is the call I'm using. It returns a url but when passing it to AIO it still returns the same error message, "Access is forbidden".

var signedPutURL = await getSignedPostUrl(putKey, bucket);

export async function getSignedPostUrl(key: string, bucket: string, expireAfterMinutes: number = 0, options = null):Promise<string>{
    const s3 = new AWS.S3();
    var params = {
        Bucket: bucket,
        Fields: {
          Key: key,
          ContentType: "application/octet-stream",
        }
    };

    if (options) {
        params = Object.assign(params, options);
    }

    const presignedPost = await s3.createPresignedPost(params);
    const url = presignedPost.url;
    return url;
}
velara3 commented 8 months ago

Please! Don't everyone answer at once!

velara3 commented 7 months ago

Well, it was solved. It was related to defining a put url that matches the schema sent by the PS API. I can't find the page now but it was a page on storage on the aio sdk code examples page. I'm not going to link to it because no one is answering this forum. So why help others if no one helped me?! That's the boomer philosophy. Why prevent the suffering of others if I had to suffer so should they. So I'm not going to link to it. Let the suffering continue. No one is preventing suffering through this forum. Why improve or upgrade the world. Why do anything good!?