Giter Club home page Giter Club logo

Comments (5)

miketeo avatar miketeo commented on September 27, 2024

@Mannshoch : Can you provide an estimate on the file size before your app runs out of RAM?

from pysmb.

Mannshoch avatar Mannshoch commented on September 27, 2024

I have planned to backup a ~16GB ZIP form a WebDAV with as cron job once a month onto a NAS. My Router has 2GB RAM (around 1.4GB is unused). It is possible to ask WebDAV (webdavclient3) for the file size.

from pysmb.

miketeo avatar miketeo commented on September 27, 2024

The issue might be that your app is trying to read the entire zip into memory before uploading to your NAS.
If you can read your zip file in smaller chunks from your WebDAV server, you can use pysmb's storeFileFromOffset to upload each chunk of data at the last offset.

from pysmb.

Mannshoch avatar Mannshoch commented on September 27, 2024

that's my current code:

for filename in webdav_fs.ls(webdav_pfad, detail=False):
    webdav_file_path = os.path.join(filename)
    smb_file_path = os.path.join(smb_path, filename)
    file_size = webdav_fs.info(webdav_file_path)['size']
    offset = 0
    chunk_size = 8 * 1024  # 8KB
    f = io.BytesIO()
    webdav_client.download_fileobj(webdav_file_path, f)
    f.seek(0)  
    while True:
        chunk = f.read(chunk_size)
        if not chunk:
            break
        smb_conn.storeFileFromOffset(smb_service_name, smb_file_path, f, offset=offset)
        offset += len(chunk)

from pysmb.

miketeo avatar miketeo commented on September 27, 2024

webdav_client.download_fileobj(webdav_file_path, f)
This line will download the entire WebDAV file into the memory.
Please check if your client can download the file in chunks from the remote WebDAV server.

from pysmb.

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.