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

Images are not complete and show grey background #3164

Closed
SilverFoxA opened this issue Mar 18, 2020 · 8 comments
Closed

Images are not complete and show grey background #3164

SilverFoxA opened this issue Mar 18, 2020 · 8 comments
Assignees
Labels
bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Comments

@SilverFoxA
Copy link

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
In my application, I'm allowing admins to upload products in bulk. In the excel sheet, admin can add multiple images. The images are the link of google drive photos. The application downloads the image from google drive and stores it in the local webserver. Which looks like this: https://i.imgur.com/qOWoMGn.jpg

When I upload using the SDK to AWS S3, it looks like this: https://i.imgur.com/tbDcSfR.jpg

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
v13.7.0

SDK version number
"aws-sdk": "^2.524.0",

To Reproduce (observed behavior)
We couldn't trace the issue of why, as it happens with few where the others are just fine.

Expected behavior
It's should display me the complete image.

Screenshots
Original Image: https://i.imgur.com/qOWoMGn.jpg
Faulty Image: https://i.imgur.com/tbDcSfR.jpg

Additional context
Add any other context about the problem here.

@SilverFoxA SilverFoxA added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 18, 2020
@ajredniwja ajredniwja self-assigned this Mar 18, 2020
@ajredniwja
Copy link
Contributor

Hey @SilverFoxA thank-you for reaching out, can you please share repro code.

Do you see any errors when a faulty picture is uploaded?

@ajredniwja ajredniwja added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Mar 19, 2020
@SilverFoxA
Copy link
Author

Hello @ajredniwja ,

Hope you are doing well.
Thank you for your prompt response.
The codebase is deployed to live server and was working for almost half a year now and everything was working as expected.

This issue started 2-3days back, I'm assuming it has something to do with the latest changes to AWS S3 - just an assumption.

Here's the codebase

UploadToS3Queue.js

const aws = new AWSS3().upload(data.filePath, data.keyName ? data.keyName : data.filePath, data);
//console.log("AWS",aws)
if (aws)
    aws.then(async res => {
        //console.log('Response', res)
        // console.log(
        //     The URL is ${res.Location}
        // );

        data['link'] = res.Location

        // perform database operation to update the database with AWS S3 image link
        await performImageDBOps(data)

        // deleteLocalFile(data.filePath)
        done()
    }).catch(reason => {
        done(reason)
        //console.log('Reason', reason)
    });

UploadLogic

async upload(filepath, keyName, options) {

    if (filepath[0] === '/') {
        filepath = filepath.substr(1)
    }

    // Create params for putObject call
    const objectParams = {
        Bucket: awsConfig.AWS_BUCKET_ASSETS,
        Key: (keyName ? keyName : filepath).replace('upload_', '').replace('uploads', 'static'),
        Body: fs.readFileSync(filepath),
        ACL: 'public-read',
        CacheControl: 'max-age=86400',
        //Expires:'',
        //Metadata:''
    };

    //console.log(objectParams)
    // Create object upload promise
    return new AWS.S3(config).upload(objectParams).promise();
}

Please let me know if you need any further information regarding the same.

The file got uploaded, I got a success response.

@ajredniwja ajredniwja removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Mar 20, 2020
@ajredniwja
Copy link
Contributor

I am able to upload images successfully using the code snippet that you provided.

Is there anything that you have noticed, any pattern or special case where it fails every-time?

@ajredniwja ajredniwja added the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Mar 27, 2020
@SilverFoxA
Copy link
Author

SilverFoxA commented Apr 1, 2020

I haven't been able to get to any conclusion as couldn't find any valid reason behind the output.

I have shared the image using which I was able to replicate the error. I'm also facing another problem because of this upload issue, which I have posted here: aws-solutions/serverless-image-handler#197

@ajredniwja
Copy link
Contributor

@SilverFoxA, as mentioned there in the thread as well, I am not able to reproduce the error as well.

Do you see any error when the picture is uploaded?
Do you see the error every-time you upload this picture?

@ajredniwja ajredniwja added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. and removed response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. labels Apr 1, 2020
@SilverFoxA
Copy link
Author

There's no error as pointed earlier.

@ajredniwja
Copy link
Contributor

Closing this issue now, reach out if you have additional questions.

@lock
Copy link

lock bot commented Apr 17, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants