@@ -72,6 +72,61 @@ static Files getInstance()
72
72
return instance ;
73
73
}
74
74
75
+ public BackendlessFile upload ( String urlToFile , String backendlessPath )
76
+ {
77
+ return upload ( urlToFile , backendlessPath , false );
78
+ }
79
+
80
+ public BackendlessFile upload ( String urlToFile , String backendlessPath , boolean overwrite )
81
+ {
82
+ if ( urlToFile == null || urlToFile .isEmpty () )
83
+ throw new NullPointerException ( ExceptionMessage .NULL_URL_TO_FILE );
84
+
85
+ if ( backendlessPath == null )
86
+ throw new NullPointerException ( ExceptionMessage .NULL_PATH );
87
+
88
+ final String resultURL = Invoker .invokeSync ( FILE_MANAGER_SERVER_ALIAS , "upload" , new Object [] { urlToFile , backendlessPath , overwrite } );
89
+ return new BackendlessFile ( resultURL );
90
+ }
91
+
92
+ public void upload ( String urlToFile , String backendlessPath , AsyncCallback <BackendlessFile > responder )
93
+ {
94
+ upload ( urlToFile , backendlessPath , false , responder );
95
+ }
96
+
97
+ public void upload ( String urlToFile , String backendlessPath , boolean overwrite , final AsyncCallback <BackendlessFile > responder )
98
+ {
99
+ try
100
+ {
101
+ if ( urlToFile == null || urlToFile .isEmpty () )
102
+ throw new NullPointerException ( ExceptionMessage .NULL_URL_TO_FILE );
103
+
104
+ if ( backendlessPath == null )
105
+ throw new NullPointerException ( ExceptionMessage .NULL_PATH );
106
+
107
+ Invoker .invokeAsync ( FILE_MANAGER_SERVER_ALIAS , "upload" , new Object [] { urlToFile , backendlessPath , overwrite }, new AsyncCallback <String >()
108
+ {
109
+ @ Override
110
+ public void handleResponse ( String response )
111
+ {
112
+ responder .handleResponse ( new BackendlessFile ( response ) );
113
+ }
114
+
115
+ @ Override
116
+ public void handleFault ( BackendlessFault fault )
117
+ {
118
+ if ( responder != null )
119
+ responder .handleFault ( fault );
120
+ }
121
+ } );
122
+ }
123
+ catch ( Throwable e )
124
+ {
125
+ if ( responder != null )
126
+ responder .handleFault ( new BackendlessFault ( e ) );
127
+ }
128
+ }
129
+
75
130
public BackendlessFile upload ( File file , String path ) throws Exception
76
131
{
77
132
return upload ( file , path , false );
0 commit comments