FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

iOS: HttpContent.toFile() does not save if the file does not exist · Issue #3870 · NativeScript/NativeScript · GitHub

iOS: HttpContent.toFile() does not save if the file does not exist #3870

Description

With this code:

const response = await http.request({
    url: "https://raw.githubusercontent.com/NativeScript/NativeScript/master/apps/tests/logo.png",
    method: "GET",
});
const filePath = fs.path.join(fs.knownFolders.temp().path, "test", "logo.png");
const file = response.content.toFile(filePath);
console.log("FILE LENGTH: " + file.readSync().length);

The file length that gets logged is 0.

While the following code:

const response = await http.request({
    url: "https://raw.githubusercontent.com/NativeScript/NativeScript/master/apps/tests/logo.png",
    method: "GET",
});
const file = fs.knownFolders.temp().getFolder("test1").getFile("logo.png");
response.content.toFile(file.path);
console.log("FILE LENGTH: " + file.readSync().length);

Works ok and the file length is non-zero.

I would expect when the file does not exists the method to automatically create the file and write the contents to the file.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL