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 large file upload support #33

Merged
merged 15 commits into from
Jan 9, 2022
Merged

Add large file upload support #33

merged 15 commits into from
Jan 9, 2022

Conversation

smk762
Copy link
Contributor

@smk762 smk762 commented Jan 6, 2022

I noticed that while using this package on large files it wouldn't work as expected, and found the reason to be related to https://developers.virustotal.com/reference/files-upload-url

This PR will allow for large file upload by setting a boolean param large_file and using a generated large file upload URL as the resource param.

Example:

# Get large file URL
r = vtotal.request("files/upload_url", method="GET")
upload_url = r.json()["data"]

# Upload a large file
files = {"file": (os.path.basename(file_with_path), open(os.path.abspath(file_with_path), "rb"))}
r = vtotal.request(upload_url, files=files, method="POST", large_file=True)

Real world example at https://github.com/smk762/draft_adex_release/blob/main/lib_virustotal.py#L26

@dbrennand dbrennand self-requested a review January 6, 2022 09:00
@dbrennand dbrennand self-assigned this Jan 6, 2022
@dbrennand dbrennand added the enhancement New feature or request label Jan 6, 2022
@dbrennand
Copy link
Owner

Hi @smk762

Thank you for your contribution! 👍🏻

I'll take a proper look and test myself as soon as I can 😃

@dbrennand
Copy link
Owner

Hi @smk762

I have reached out to VirusTotal support to see if they can grant my account with the access needed to test the equivilent v2 API endpoint.

https://developers.virustotal.com/v2.0/reference/file-scan-upload-url

@dbrennand
Copy link
Owner

Hi @smk762

I have reached out to VirusTotal support to see if they can grant my account with the access needed to test the equivilent v2 API endpoint.

https://developers.virustotal.com/v2.0/reference/file-scan-upload-url

VirusTotal support granted my account access to the v2 equivalent endpoint however, I've been unable to get it working. Every time I try to submit a file for analysis it returns a HTTP 500 internal server error.

The v3 API endpoint worked without any issue 👍🏻

I will push the tests I've written later today 🙂

I might have to reach out to VirusTotal support (re: HTTP 500 error) however, its not to big of a deal as VirusTotal:

"highly recommend to use our APIv3, which is now the default and encouraged way to programmatically interact with VirusTotal."

Copy link
Owner

@dbrennand dbrennand left a comment

Choose a reason for hiding this comment

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

LGTM

@dbrennand dbrennand merged commit a729191 into dbrennand:master Jan 9, 2022
@dbrennand
Copy link
Owner

Hi @smk762

Thank you so much for your contribution! ❤️

I have released 0.2.0 with this functionality implemented into the library! 👍🏻 🙂

@smk762
Copy link
Contributor Author

smk762 commented Jan 10, 2022

Cheers mate, thanks for the credit and quick turnaround :)

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

Successfully merging this pull request may close these issues.

2 participants