Ejemplo n.º 1
0
        public static Task <ResultHolder <XMLHttpRequest> > Upload(
            string interfaceName, string methodName, IEnumerable <Bridge.Html5.File> uploaded,
            FileUploadOperation operation, RemoteFileId toReplaceOrRemoveId, string jsonizedInput)
        {
            //for FormData upload see https://stackoverflow.com/questions/6133800/html5-file-api-readasbinarystring-reads-files-as-much-larger-different-than-fil/6142797#6142797

            var uploadData = new FormData();

            uploaded.ForEachI((i, x) => uploadData.Append("file" + i, x));
            uploadData.Append("operation", ((int)operation).ToString());
            uploadData.Append("toReplaceOrRemoveId", JSON.Stringify(toReplaceOrRemoveId));
            uploadData.Append("i", jsonizedInput);

            return(Task.FromPromise <ResultHolder <XMLHttpRequest> >(
                       new XMLHttpRequestImplementingIPromise("POST", $"/{interfaceName}/{methodName}", uploadData),
                       (Func <ResultHolder <XMLHttpRequest>, ResultHolder <XMLHttpRequest> >)(x => x)));
        }
Ejemplo n.º 2
0
        public async Task <RemoteFileId[]> Upload(
            IEnumerable <Bridge.Html5.File> uploaded, FileUploadOperation operation, RemoteFileId toReplaceOrRemoveId)
        {
            var input = _input?.Invoke();
            var res   = await XMLHttpRequestUtils.Upload(
                _interfaceName, _setterMethod, uploaded, operation, toReplaceOrRemoveId, input);

            if (!res.Success)
            {
                throw new Exception(res.Result.ResponseText);
            }

            var output = res.Result.Response;

            Logger.Debug(GetType(), "upload success file id json is {0}", output);
            return(JsonConvert.DeserializeObject <RemoteFileId[]>(
                       BridgeObjectUtil.NoOpCast <string>(output)));
        }
Ejemplo n.º 3
0
 public string BuildDownloadUrl(RemoteFileId id)
 {
     return(_httpRequester.BuildUrl(_interfaceName, _getterMethod, _downloadSer(id)));
 }
Ejemplo n.º 4
0
 public Task <FileModel> Download(RemoteFileId id)
 {
     return(_httpRequester.RunHttpRequestReturningAttachmentImplStr(
                _interfaceName, _getterMethod, _downloadSer(id)));
 }