Skip to content

HTTP status code evaluation from ops? #121

Description

@Schachte

First off, I'm happy I remembered this lib exists! Realized we hacked together a nice solution to an existing problem that is helping me out today here:
#57

So thank you for the continued support on this project.

Now this may be a dumb question, but I'm playing around with the SDK and realizing there is no way for me to get the status code from the operations I invoke, is this correct?

    const putResponse = await s3Client.putObject(bucket, objectKey, data, {
      contentType: 'application/octet-stream',
      contentLength: objectSize,
    });

    const getResponse = await s3Client.getObject(bucket, objectKey);

    check(getResponse, {
      'GET operation successful': (r) => r.status === 200,
    });
    
    if (getResponse.status !== 200) {
      result.error = 'GET operation failed';
      return result;
    }

Take this for example. putResponse is undefined. How would I accurately report on putObject failure counts if this is always undefined?

Is it just like this?

  check(putResponse, {
    'PUT operation successful': (r) => r === undefined, // No error means success
  });

I'd also like assurance that object corruption wasn't present in transit by comparing hashes (etag), which we typically get from putobject.

My current form is:

    const putResponse = await s3Client.putObject(bucket, objectKey, data, {
      contentType: 'application/octet-stream',
      contentLength: objectSize,
    });
    check(putResponse, {
      'PUT operation successful': (r) => r === undefined
    });

    const getResponse = await s3Client.getObject(bucket, objectKey);
    check(getResponse, {
      'GET operation successful': (r) => r.key === objectKey && r.size === objectSize,
    });
    
    const deleteResponse = await s3Client.deleteObject(bucket, objectKey);
    check(deleteResponse, {
      'DELETE operation successful': (r) => r === undefined,
    });

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Fields

No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions