Alfresco REST API:数据大小限制?

时间:2013-01-25 05:28:16

标签: rest alfresco

我正在露天开发基于REST的网络服务,用于数据传输和扩展。想知道我可以通过REST协议发送/获取的最大数据量是多少?

任何参考都会非常有用。

问候。

1 个答案:

答案 0 :(得分:2)

最大数据量大到2147000000.这就是为什么如果您的数据足够大,建议将其流式传输到您的REST服务。这是一个例子。

发件人/上传者应用程序或客户

        var sb = new StringBuilder();
        sb.Append("Just test data. You can send large one also");
        var postData = sb.ToString();
        var url = "REST Post method example http://localhost:2520/DataServices/TestPost";
        var memoryStream = new MemoryStream();
        var dataContractSerializer = new DataContractSerializer(typeof(string));
        dataContractSerializer.WriteObject(memoryStream, postData);
        var xmlData = Encoding.UTF8.GetString(memoryStream.ToArray(), 0, (int)memoryStream.Length);
        var client = new WebClient();
        client.UploadStringAsync(new Uri(url), "POST", "");
        client.Headers["Content-Type"] = "text/xml";
        client.UploadStringCompleted += (s, ea) =>
        {
            if (ea.Error != null) Console.WriteLine("An error has occured while processing your request");
            var doc = XDocument.Parse(ea.Result);
            if (doc.Root != null) Console.WriteLine(doc.Root.Value);
            if (doc.Root != null && doc.Root.Value.Contains("1"))
            {
                string test = "test";
            }
        };

REST服务方法

[WebInvoke(UriTemplate = "TestPost", Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Xml)]
    public string Publish(string market,string sportId, Stream streamdata)
    {
        var reader = new StreamReader(streamdata);
        var res = reader.ReadToEnd();
        reader.Close();
        reader.Dispose();

    }

不要忘记在REST服务配置文件中放置以下配置设置如果没有这个设置会导致错误

<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147000000" maxQueryStringLength="2097151" maxUrlLength="2097151"/>
  </system.web>
  <system.webServer>
    ........
  </system.webServer>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="2147000000" maxBufferPoolSize="2147000000" maxBufferSize="2147000000"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>