Giter Site home page Giter Site logo

Upload to S3 Failing about ctfd HOT 9 CLOSED

Thomas-McKanna avatar Thomas-McKanna commented on June 2, 2024
Upload to S3 Failing

from ctfd.

Comments (9)

ColdHeat avatar ColdHeat commented on June 2, 2024

This could be related to #2432 but I am unsure since I have not seen S3 uploads breaking. Can you perhaps set your timezone to UTC to see if that allows uploads to work? That will help confirm the source of the issue.

from ctfd.

Thomas-McKanna avatar Thomas-McKanna commented on June 2, 2024

@ColdHeat I did some digging. It looks like the boto3 upload_fileobj function silently closes the file object you give it after upload (see boto/boto3#929).

This unfortunate undocumented behavior, along with the addition of

sha1sum = hash_file(fp=file_obj)
in the last release it causing the issue, since this line occurs after the called to upload_fileobj. This explains why the returned error is "I/O operation on closed file.".

I guess this would only be a problem if using S3 to store files for CTFd.

from ctfd.

ColdHeat avatar ColdHeat commented on June 2, 2024

Thank you for digging into this and figuring out the issue. This is an issue in a feature for 3.7 which explains why I haven't seen it before.

You're welcome to PR a fix but I will tackle this as part of 3.7 as well.

from ctfd.

ColdHeat avatar ColdHeat commented on June 2, 2024

Likely the simplest fix is to calculate the SHA before uploading because we don't close the file and re-seek to the beginning as well.

from ctfd.

Thomas-McKanna avatar Thomas-McKanna commented on June 2, 2024

@ColdHeat I can confirm that moving the hash calculated to before the file upload fixes the issue. I can submit a PR. Any idea when this might be pushed to a new hotfix version (maybe 3.6.2?)? This issue is currently causing me some trouble in preparing for an upcoming event.

from ctfd.

ColdHeat avatar ColdHeat commented on June 2, 2024

Thanks for the PR I stepped out before I could put one up.

I think I would rather wait for 3.7.0. There isn't a significant amount of difference between 3.6.1 and the current commit: 3.6.1...master so if you having issues you could just specifically pin to the 3.6.1 image or to that tag/commit.

from ctfd.

Thomas-McKanna avatar Thomas-McKanna commented on June 2, 2024

Ok, I'll make it work somehow. I was having some issues with pinning to a tag/commit because it seemed to throw off the database.

from ctfd.

ColdHeat avatar ColdHeat commented on June 2, 2024

I think now that your fix is merged you should be able to run off of that since the shasum change is the only change that modified the database.

from ctfd.

Thomas-McKanna avatar Thomas-McKanna commented on June 2, 2024

@ColdHeat Yep that worked. Thank you!

from ctfd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.