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

Add file path -> crc32 algorithm #23

Merged
merged 2 commits into from
Aug 27, 2024
Merged

Add file path -> crc32 algorithm #23

merged 2 commits into from
Aug 27, 2024

Conversation

MrCreosote
Copy link
Member

Can use the base64 encoded crc to validate uploads like so:

In [56]: fields
Out[56]:
{'key': 'somefile',
 'AWSAccessKeyId': 'admin',
 'policy':
'eyJleHBpcmF0aW9uIjogIjIwMjQtMDgtMjZUMjM6MzE6MDBaIiwgImNvbmRpdGlvbnMiOiBbeyJidWNrZXQiOiAidGVzdCJ9LCB7ImtleSI6ICJzb21lZmlsZSJ9XX0=',
 'signature': 'Ys4tVhnbR1fUrMgpm+1DRxXsWnY=',
 'x-amz-checksum-crc32': b'bwUq9A=='}

In [57]: with open("Dockerfile") as f:
    ...:     files = {"file": ("somefile", f)}
    ...:     res = requests.post(url["url"], data=fields, files=files)

Can use the base64 encoded crc to validate uploads like so:

```
In [56]: fields
Out[56]:
{'key': 'somefile',
 'AWSAccessKeyId': 'admin',
 'policy':
'eyJleHBpcmF0aW9uIjogIjIwMjQtMDgtMjZUMjM6MzE6MDBaIiwgImNvbmRpdGlvbnMiOiBbeyJidWNrZXQiOiAidGVzdCJ9LCB7ImtleSI6ICJzb21lZmlsZSJ9XX0=',
 'signature': 'Ys4tVhnbR1fUrMgpm+1DRxXsWnY=',
 'x-amz-checksum-crc32': b'bwUq9A=='}

In [57]: with open("Dockerfile") as f:
    ...:     files = {"file": ("somefile", f)}
    ...:     res = requests.post(url["url"], data=fields, files=files)

```
@MrCreosote MrCreosote requested a review from Tianhao-Gu August 27, 2024 16:16
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.88%. Comparing base (4622caf) to head (e9fe607).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   98.84%   98.88%   +0.04%     
==========================================
  Files           6        6              
  Lines         259      270      +11     
==========================================
+ Hits          256      267      +11     
  Misses          3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Tianhao-Gu Tianhao-Gu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@MrCreosote MrCreosote merged commit 926faad into main Aug 27, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants