Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-12439] Incomplete file download on Ubuntu #4392

Closed
swift-ci opened this issue Mar 28, 2020 · 2 comments
Closed

[SR-12439] Incomplete file download on Ubuntu #4392

swift-ci opened this issue Mar 28, 2020 · 2 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-12439
Radar rdar://problem/62201041
Original Reporter vballoli (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

MacOS 10.15: Swift version - 5.1.1-dev

Ubuntu 18.04: Swift version - 5.2-dev

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: ec39e828733ecb8c8d2b83067fba2c43

is duplicated by:

  • SR-12892 Data(contentsOf:) does not follow redirects on Linux

Issue Description:

Using the `URL` and Data classes, I'm trying to download a zip file from GitHub using the following code:

import Foundation
import FoundationNetworking

let url = URL(string: "https://github.com/brendenlake/omniglot/raw/master/python/images_background_small1.zip")!
let file = try Data(contentsOf: url)
file.write(to: URL(fileURLWithPath: "~/test.zip"))

On MacOS, this runs just fine(returns 1319022 bytes), while on Ubuntu 18, around 160 bytes is only downloaded, resulting in an incomplete download.

@beccadax
Copy link
Contributor

@swift-ci create

@spevans
Copy link
Collaborator

spevans commented May 5, 2020

This is due to a 302 redirect not being followed, and has been fixed in the master branch.

$ cat sr-12439.swift 
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

let url = URL(string: "https://github.com/brendenlake/omniglot/raw/master/python/images_background_small1.zip")!
let file = try Data(contentsOf: url)
print("Read \(file.count) bytes")
try! file.write(to: URL(fileURLWithPath: "test.zip"))

$ ~/swift-DEVELOPMENT-SNAPSHOT-2020-05-03-a-ubuntu18.04/usr/bin/swift sr-12439.swift 
Read 1319022 bytes
$ ls -l test.zip 
-rw------- 1 501 dialout 1319022 May  4 23:28 test.zip
$ 

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants