question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get-S3ObjectAttribute doesn't return parts

See original GitHub issue

Describe the bug

I tried to use Get-S3ObjectAttribute to return parts of a multipart uploaded file (via web UI) to do the checksum of these, but no parts are returned.,

Expected Behavior

When you call the Get-S3ObjectAttribute cmdlet, I expect that Parts {} array is populated if the upload is multipart, like the TotalPartsCount property indicates correctly.

Current Behavior

The Parts {} is empty, even if the property TotalPartsCount is different from 0.

Reproduction Steps

$bucket = "mybucket" # I suppose, for this issue that my file to query is in the first position of my bucket $obj = (Get-S3Object -BucketName $bucket)[0] # Pass the object to the cmdlet $obj | Get-S3ObjectAttribute -ObjectAttributes Checksum,ObjectParts -Select ObjectParts

The result is something like this:

IsTruncated : True MaxParts : 1000 NextPartNumberMarker : 1000 PartNumberMarker : 0 Parts : {} TotalPartsCount : 1076

Possible Solution

No response

Additional Information/Context

No response

AWS Tools for PowerShell version used

AWS Tools for PowerShell Version 4.1.241 Copyright 2012-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET Core Runtime Version 3.7.103.8 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

PowerShell version used

Name Value


PSVersion 5.1.19041.2364 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} BuildVersion 10.0.19041.2364 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Operating System and version

Windows 10

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ashishdhingracommented, Apr 13, 2023

Reproducible using below code:

using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.S3.Transfer;

string filePath = "<<absolute-path-to-file>>;
string bucketName = "<<bucket-name>>";
string objectKey = "<<key-name>>";

Amazon.AWSConfigs.LoggingConfig.LogResponses = Amazon.ResponseLoggingOption.Always;
Amazon.AWSConfigs.LoggingConfig.LogTo = Amazon.LoggingOptions.SystemDiagnostics;
Amazon.AWSConfigs.AddTraceListener("Amazon", new System.Diagnostics.ConsoleTraceListener());

using (AmazonS3Client amazonS3Client = new AmazonS3Client(RegionEndpoint.USEast2))
{
    TransferUtilityUploadRequest transferUtilityUploadRequest = new TransferUtilityUploadRequest()
    {
        FilePath = filePath,
        BucketName = bucketName,
        Key = objectKey,
        ChecksumAlgorithm = ChecksumAlgorithm.CRC32
    };

    TransferUtility transferUtility = new TransferUtility(amazonS3Client);
    await transferUtility.UploadAsync(transferUtilityUploadRequest);

    // Get the object attributes.
    GetObjectAttributesRequest getObjectAttributesRequest = new GetObjectAttributesRequest()
    {
        BucketName = bucketName,
        Key = objectKey,
        ObjectAttributes = new List<ObjectAttributes>()
        {
            new ObjectAttributes("Checksum"),
            new ObjectAttributes("ObjectParts"),
            new ObjectAttributes("ObjectSize")
        }
    };

    GetObjectAttributesResponse getObjectAttributesResponse = await amazonS3Client.GetObjectAttributesAsync(getObjectAttributesRequest);
    Console.WriteLine("Object Total Parts Count: " + getObjectAttributesResponse.ObjectParts.TotalPartsCount);
    Console.WriteLine("Object Parts Length: " + getObjectAttributesResponse.ObjectParts.Parts.Count);
}

We need to add dependency on AWSSDK.Extensions.CrtIntegration to use custom ChecksumAlgorithm.

Running the code returns the below verbose logging which shows that Part(s) information is returned by S3 service when using non-default ChecksumAlgorithm.

...
Amazon Verbose: 5 : Waiting for upload part requests to complete. (6IVYf5NA4UIZ4y9lumX8TiI3VbXo6qnG_R8LwyYymi5ef2snmy7s5F6nXeq0eLV5s7uAs4_hog09KQXAQZXbzW8Ahxf50yYrDQchEAtuUXYzslxgeJBGwGbNn7qXHtbTOKuMs0jFiyW9w0VoskrxRQ--)
Amazon Verbose: 48 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 49 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 50 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 51 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 52 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 53 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 54 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 55 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 56 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 57 : Received response (truncated to 1024 bytes): []
Amazon Verbose: 6 : Beginning completing multipart. (6IVYf5NA4UIZ4y9lumX8TiI3VbXo6qnG_R8LwyYymi5ef2snmy7s5F6nXeq0eLV5s7uAs4_hog09KQXAQZXbzW8Ahxf50yYrDQchEAtuUXYzslxgeJBGwGbNn7qXHtbTOKuMs0jFiyW9w0VoskrxRQ--)
Amazon Verbose: 60 : Single encoded /dev.zip with endpoint https://testbucket-issue1880.s3.us-east-2.amazonaws.com/ for canonicalization: /dev.zip
Amazon Verbose: 58 : Received response (truncated to 1024 bytes): [<?xml version="1.0" encoding="UTF-8"?>

<CompleteMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Location>https://testbucket-issue1880.s3.us-east-2.amazonaws.com/dev.zip</Location><Bucket>testbucket-issue1880</Bucket><Key>dev.zip</Key><ETag>"3b0b854ef7902b089bcf85e1d1708812-57"</ETag><ChecksumCRC32>KRO/JA==-57</ChecksumCRC32></CompleteMultipartUploadResult>]
Amazon Verbose: 7 : Done completing multipart. (6IVYf5NA4UIZ4y9lumX8TiI3VbXo6qnG_R8LwyYymi5ef2snmy7s5F6nXeq0eLV5s7uAs4_hog09KQXAQZXbzW8Ahxf50yYrDQchEAtuUXYzslxgeJBGwGbNn7qXHtbTOKuMs0jFiyW9w0VoskrxRQ--)
Amazon Verbose: 61 : Single encoded /dev.zip with endpoint https://testbucket-issue1880.s3.us-east-2.amazonaws.com/ for canonicalization: /dev.zip
Amazon Verbose: 59 : Received response (truncated to 1024 bytes): [<?xml version="1.0" encoding="UTF-8"?>
<GetObjectAttributesResponse xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Checksum><ChecksumCRC32>KRO/JA==</ChecksumCRC32></Checksum><ObjectParts><PartsCount>57</PartsCount><PartNumberMarker>0</PartNumberMarker><NextPartNumberMarker>57</NextPartNumberMarker><MaxParts>1000</MaxParts><IsTruncated>false</IsTruncated><Part><PartNumber>1</PartNumber><Size>5242880</Size><ChecksumCRC32>Q878cw==</ChecksumCRC32></Part><Part><PartNumber>2</PartNumber><Size>5242880</Size><ChecksumCRC32>s6KX7A==</ChecksumCRC32></Part><Part><PartNumber>3</PartNumber><Size>5242880</Size><ChecksumCRC32>z/1ORA==</ChecksumCRC32></Part><Part><PartNumber>4</PartNumber><Size>5242880</Size><ChecksumCRC32>/GSlhQ==</ChecksumCRC32></Part><Part><PartNumber>5</PartNumber><Size>5242880</Size><ChecksumCRC32>c+sFig==</ChecksumCRC32></Part><Part><PartNumber>6</PartNumber><Size>5242880</Size><ChecksumCRC32>zeaUGw==</ChecksumCRC32></Part><Part><PartNumber>7</PartNumber><Size>5242880</Size><ChecksumCRC32>Fn8vyw==</C]
Object Total Parts Count: 57
Object Parts Length: 0
0reactions
github-actions[bot]commented, May 8, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GetObjectAttributes - Amazon Simple Storage Service
Retrieves all the metadata from an object without returning the object itself. This action is useful if you're interested only in an object's...
Read more >
s3.GetObjectAttributes does not encode the X-Amz-Object- ...
Using -debug in the aws cli, I see that the attributes are comma separated. ... The issue doesn't seem to happen with single...
Read more >
get-object-attributes
GetObjectAttributes combines the functionality of HeadObject and ListParts . All of the data returned with each of those individual calls can be returned...
Read more >
S3 getObjectCommand doesn't return the latest version of ...
I am using react and i am trying to get a json file from S3. This is the package i use: "@aws-sdk/client-s3": "^3.332.0"...
Read more >
Working with really large objects in S3
Code for processing large objects in S3 without downloading the whole thing first, using file-like objects in Python.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found