コード例 #1
0
ファイル: httputils.java プロジェクト: jackcaicn/b4a.mblogs
 public static anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _getinputstream(
     anywheresoftware.b4a.BA _ba, String _url) throws Exception {
   anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _in = null;
   // BA.debugLineNum = 107;BA.debugLine="Sub GetInputStream(URL As String) As InputStream";
   // BA.debugLineNum = 108;BA.debugLine="Dim In As InputStream";
   _in = new anywheresoftware.b4a.objects.streams.File.InputStreamWrapper();
   // BA.debugLineNum = 109;BA.debugLine="If IsSuccess(URL) = False Then";
   if (_issuccess(_ba, _url) == anywheresoftware.b4a.keywords.Common.False) {
     // BA.debugLineNum = 110;BA.debugLine="Log(\"Task not completed successfully.\")";
     anywheresoftware.b4a.keywords.Common.Log("Task not completed successfully.");
     // BA.debugLineNum = 111;BA.debugLine="Return In";
     if (true) return _in;
   }
   ;
   // BA.debugLineNum = 113;BA.debugLine="In = File.OpenInput(HttpUtilsService.TempFolder,
   // SuccessfulUrls.Get(URL))";
   _in =
       anywheresoftware.b4a.keywords.Common.File.OpenInput(
           mostCurrent._httputilsservice._tempfolder,
           String.valueOf(_successfulurls.Get((Object) (_url))));
   // BA.debugLineNum = 114;BA.debugLine="Return In";
   if (true) return _in;
   // BA.debugLineNum = 115;BA.debugLine="End Sub";
   return null;
 }
コード例 #2
0
ファイル: httputils.java プロジェクト: jackcaicn/b4a.mblogs
 public static String _postfile(
     anywheresoftware.b4a.BA _ba, String _jobname, String _url, String _dir, String _filename)
     throws Exception {
   int _length = 0;
   anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _in = null;
   anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _out = null;
   // BA.debugLineNum = 34;BA.debugLine="Sub PostFile(JobName As String, URL As String, Dir As
   // String, FileName As String)";
   // BA.debugLineNum = 35;BA.debugLine="If internalCheckIfCanStart(JobName) = False Then Return";
   if (_internalcheckifcanstart(_ba, _jobname) == anywheresoftware.b4a.keywords.Common.False) {
     if (true) return "";
   }
   ;
   // BA.debugLineNum = 36;BA.debugLine="Dim length As Int";
   _length = 0;
   // BA.debugLineNum = 37;BA.debugLine="If Dir = File.DirAssets Then";
   if ((_dir).equals(anywheresoftware.b4a.keywords.Common.File.getDirAssets())) {
     // BA.debugLineNum = 38;BA.debugLine="Log(\"Cannot send files from the assets folder.\")";
     anywheresoftware.b4a.keywords.Common.Log("Cannot send files from the assets folder.");
     // BA.debugLineNum = 39;BA.debugLine="Return";
     if (true) return "";
   }
   ;
   // BA.debugLineNum = 41;BA.debugLine="length = File.Size(Dir, FileName)";
   _length = (int) (anywheresoftware.b4a.keywords.Common.File.Size(_dir, _filename));
   // BA.debugLineNum = 42;BA.debugLine="Dim In As InputStream";
   _in = new anywheresoftware.b4a.objects.streams.File.InputStreamWrapper();
   // BA.debugLineNum = 43;BA.debugLine="In = File.OpenInput(Dir, FileName)";
   _in = anywheresoftware.b4a.keywords.Common.File.OpenInput(_dir, _filename);
   // BA.debugLineNum = 44;BA.debugLine="If length < 1000000 Then '1mb";
   if (_length < 1000000) {
     // BA.debugLineNum = 47;BA.debugLine="Dim out As OutputStream";
     _out = new anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper();
     // BA.debugLineNum = 48;BA.debugLine="out.InitializeToBytesArray(length)";
     _out.InitializeToBytesArray(_length);
     // BA.debugLineNum = 49;BA.debugLine="File.Copy2(In, out)";
     anywheresoftware.b4a.keywords.Common.File.Copy2(
         (java.io.InputStream) (_in.getObject()), (java.io.OutputStream) (_out.getObject()));
     // BA.debugLineNum = 50;BA.debugLine="HttpUtilsService.PostInputStream = Null";
     mostCurrent._httputilsservice._postinputstream.setObject(
         (java.io.InputStream) (anywheresoftware.b4a.keywords.Common.Null));
     // BA.debugLineNum = 51;BA.debugLine="HttpUtilsService.PostBytes = out.ToBytesArray";
     mostCurrent._httputilsservice._postbytes = _out.ToBytesArray();
   } else {
     // BA.debugLineNum = 53;BA.debugLine="HttpUtilsService.PostInputStream = In";
     mostCurrent._httputilsservice._postinputstream = _in;
     // BA.debugLineNum = 54;BA.debugLine="HttpUtilsService.PostLength = length";
     mostCurrent._httputilsservice._postlength = _length;
   }
   ;
   // BA.debugLineNum = 56;BA.debugLine="Tasks = Array As String(URL)";
   _tasks = anywheresoftware.b4a.keywords.Common.ArrayToList(new String[] {_url});
   // BA.debugLineNum = 57;BA.debugLine="HttpUtilsService.Post = True";
   mostCurrent._httputilsservice._post = anywheresoftware.b4a.keywords.Common.True;
   // BA.debugLineNum = 58;BA.debugLine="StartService(HttpUtilsService)";
   anywheresoftware.b4a.keywords.Common.StartService(
       _ba, (Object) (mostCurrent._httputilsservice.getObject()));
   // BA.debugLineNum = 59;BA.debugLine="End Sub";
   return "";
 }