Skip to content

stream get file from url for huggingface #203

@mullerhai

Description

@mullerhai

Hi,
in python ,download huggingface file ,we use requests like this,just set stream with true

import requests
fileUrl = "https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf/resolve/main/config.json?download=true"
model_url = "https://huggingface.co/bert-base-uncased/resolve/main/pytorch_model.bin"
response = requests.get(fileUrl, stream=True)
with open("muller.json", "wb") as f:
    for chunk in response.iter_content(chunk_size=8192):
        f.write(chunk)

is equal in scala? I not find to set stream =true operation

requests.get.stream(…).readWithHeaders{ (headers, stream) =>
  if (headers.statusCode == 200) {
    os.write(..., stream)
  } else {
    println("Error. Not streaming file.")
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions