Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: support transformation of AWS.S3.ManagedUpload #495

Open
1 task
jcable opened this issue Jun 2, 2023 · 2 comments
Open
1 task

[Feature]: support transformation of AWS.S3.ManagedUpload #495

jcable opened this issue Jun 2, 2023 · 2 comments
Labels
enhancement New feature or request p3 This is a minor priority issue

Comments

@jcable
Copy link

jcable commented Jun 2, 2023

Self-service

  • I'd be willing to implement this feature

Problem

When running:
npx aws-sdk-js-codemod -t v2-to-v3 example.js
I get:
Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
All done.
Results:
0 errors
1 unmodified
0 skipped
0 ok
Time elapsed: 0.340seconds

import AWS from 'aws-sdk';
import { getUploadCredentials } from './boatregisterposts';

export async function postPhotos(values, fileList) {
    if (fileList?.length > 0) {
        try {
            const r = await getUploadCredentials();
            const uploadConfig = r.data;
            AWS.config.update({
                region: uploadConfig.region,
                credentials: new AWS.CognitoIdentityCredentials({
                    IdentityPoolId: `${uploadConfig.region}:${uploadConfig.identityId}`,
                })
            });
            const uploads = fileList.map((file) => {
                const photoKey = `${values.email}/${file.name}`;
                const params = {
                    Bucket: uploadConfig.bucketName,
                    Key: photoKey,
                    ContentType: file.type,
                    Body: file,
                    Metadata: {
                        albumKey: values.albumKey,
                        copyright: values.copyright,
                    },
                };
                return new AWS.S3.ManagedUpload({ params }).promise();
            });
            return Promise.allSettled(uploads);
        } catch (e) {
            // console.log(e);
        }
    }
    return undefined;
}

Solution

I want a working v3

Alternatives

n/a

Additional context

No response

@jcable jcable added the enhancement New feature or request label Jun 2, 2023
@trivikr trivikr added the p3 This is a minor priority issue label Jul 25, 2023
@trivikr
Copy link
Member

trivikr commented Nov 2, 2023

The AWS.S3.ManagedUpload is replace by Upload in v3.
The service is renamed to client, and is no longer optional.

We added transformations for s3.upload in v0.12.0. As a workaround, you can change AWS.S3.ManagedUpload API to s3.upload and run codemod, while implementation for ManagedUpload is prioritized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants