GithubHelp home page GithubHelp logo

Comments (4)

tissieres avatar tissieres commented on June 10, 2024 1

For example I'm using django-minio-storage and their implementation of the Storage class is defined here. I would adapt your implementation to use the file storage API described in the docs instead of relying on Pathlib.

# copy uploaded file into temporary clipboard inside the default storage location
UPLOAD_TEMP_DIR.mkdir(parents=True, exist_ok=True)
file_path = Path(file_obj.name)
fh, temp_path = tempfile.mkstemp(suffix=file_path.suffix, prefix=f'{file_path.stem}.', dir=UPLOAD_TEMP_DIR)
for chunk in file_obj.chunks():
os.write(fh, chunk)
os.close(fh)
assert default_storage.size(temp_path) == file_obj.size
relative_path = Path(temp_path).relative_to(default_storage.location)
download_url = default_storage.url(relative_path)

This part could probably simplified by using the File storage API instead of doing these operations by yourself on the filesystem. Your unit test would only use this API as well and it would make your package compatible with any storage implementation. What do you think?

from django-formset.

jrief avatar jrief commented on June 10, 2024

Unfortunately I do not have any configuration using S3. Can you please point me onto some documentation where I can emulate the S3_BOTO behaviour for my unit tests. I don't want to use AWS in my unit tests.

How would you fix that?

from django-formset.

jrief avatar jrief commented on June 10, 2024

Could you please check with HEAD from main branch.

I did not try django-minio-storage or any other storage class. However I now use the proper file storage API. Thanks for reporting.

Would you make the storage class for this file upload configurable, or just keep the current default_storage?

from django-formset.

tissieres avatar tissieres commented on June 10, 2024

It's working with django-minio-storage, but I dot not explicitely use the file upload feature so far. That was the import that was failing for me.

I never use multiple storage backends so no need for it to be configurable for me.

Thank you very much for your fast fix 👍

from django-formset.

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.