Swift String index advanceBy不能取int32

时间:2015-09-24 19:31:55

标签: string swift indexing

[HttpPost]
[MultipartContentValidator]
[ActionName("uploadfile")]      
// POST /api/documents/uploadfile?folderId={folderId}&assetId={assetId}
public async Task<HttpResponseMessage> UploadFile(int folderId, int assetId)
{
    IExternalWebApiCaller _caller = new ExternalWebApiCaller();
    //## If it is not multipart, we throw it away
    if (!Request.Content.IsMimeMultipartContent("form-data"))
    {
        throw new HttpResponseException(HttpStatusCode.BadRequest);
    }

    //## Getting the juice in memory instead of the harddrive
    var provider = await Request.Content.ReadAsMultipartAsync<InMemoryMultipartFormDataStreamProvider>(new InMemoryMultipartFormDataStreamProvider());

    //## We get access to the data
    NameValueCollection formData = provider.FormData;

    //## It will access to the files
    IList<HttpContent> files = provider.Files;

    //## Reading a file as bytearray and creating the model
    //## with the filename and stuff...if any
    if (files != null)
    {
        HttpContent filetobeuploaded = files[0];
        byte[] filebytearray = await filetobeuploaded.ReadAsByteArrayAsync();

        DocumentUploadViewModel model = new DocumentUploadViewModel();
        model.AssetId = assetId;
        model.FolderId = folderId;
        model.Data = filebytearray;
        model.Filename = filetobeuploaded.Headers.ContentDisposition.FileName.Replace("\"", "");

        return await _caller.CallWebApiHttpResponseMessage("api/document/uploadfile", HttpMethod.Post, null, model, GetHeaders());
    }
    else
    {
        //## Something fail (file with no content), so we kick this out
        throw new HttpResponseException(HttpStatusCode.NoContent);
    }
}

错误代码:无法使用类型为'(Int32)'的参数列表调用'advancedBy'

我尝试过使用UInt32,它有同样的错误

1 个答案:

答案 0 :(得分:1)

更改

let s : Int32 = 4 + var

let s = Int(4 + var)