如何使用FSharp.Data的http模块下载大文件?

时间:2014-07-21 17:22:01

标签: f# f#-data

在FSharp.Data网站http://fsharp.github.io/FSharp.Data/library/Http.html中可以找到以下代码段。 TextBinary的类型分别为stringbyte[]。将整个2GB文件放入内存并将其保存到文件中并不好。

let logoUrl = "https://raw.github.com/fsharp/FSharp.Data/master/misc/logo.png"
match Http.Request(logoUrl).Body with
| Text text -> 
    printfn "Got text content: %s" text
| Binary bytes -> 
    printfn "Got %d bytes of binary content" bytes.Length

1 个答案:

答案 0 :(得分:2)

我认为您不能保留与<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <context:component-scan base-package="com.caveofprogramming.spring.test"> </context:component-scan> enter code here <beans profile="dev">`enter code here` <context:property-placeholder location="com/caveofprogramming/spring/web/test/config/jdbc.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}"></property> <property name="url" value="${jdbc.url}"></property> <property name="password" value="${jdbc.password}"></property> <property name="username" value="${jdbc.username}"></property> </bean> <!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> <prop key="javax.persistence.validation.group.pre-persist"> com.caveofprogramming.spring.web.dao.PersistenceValidationGroup </prop> <prop key="javax.persistence.validation.group.pre-update"> com.caveofprogramming.spring.web.dao.PersistenceValidationGroup </prop> <prop key="javax.persistence.validation.group.pre-remove"> com.caveofprogramming.spring.web.dao.PersistenceValidationGroup </prop> </props> </property> <property name="packagesToScan"> <list> <value>com.caveofprogramming.spring.web.dao</value> </list> </property> </bean> <!-- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="dataSource" ref="dataSource"></property> <property name="sessionFactory" value="sessionFactory"></property> </bean> <tx:annotation-driven /> <bean id="exceptionTranslator" class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"> </bean> </beans> </beans> 网站上相同的代码来下载大文件。 我用来下载大文件的是

FSharp.Data

如果您想尝试下载无限文件检查the complete source(运行风险自负,则使用The Infinite File Download