@@ -1172,20 +1172,40 @@ self.props = {
1172
1172
} ) ;
1173
1173
}
1174
1174
1175
- var tok = path . split ( '/' ) ;
1176
- var name = tok . pop ( ) ;
1177
- var parent = tok . join ( '/' ) ;
1178
- var rootId = request . searchParams . get ( 'rootId' ) || self . props . defaultRootId ;
1179
- return _await$1 ( gd . uploadByPath ( parent , name , request . body , rootId ) , function ( _gd$uploadByPath ) {
1180
- return new Response ( JSON . stringify ( _gd$uploadByPath ) , {
1181
- headers : {
1182
- 'Content-Type' : 'application/json'
1183
- }
1175
+ var url = request . searchParams . get ( 'url' ) ;
1176
+ var fileBody ;
1177
+ return _invoke ( function ( ) {
1178
+ if ( url ) {
1179
+ return _await$1 ( fetch ( url ) , function ( _fetch ) {
1180
+ fileBody = _fetch . body ;
1181
+ } ) ;
1182
+ } else {
1183
+ fileBody = request . body ;
1184
+ }
1185
+ } , function ( ) {
1186
+ var tok = path . split ( '/' ) ;
1187
+ var name = tok . pop ( ) ;
1188
+ var parent = tok . join ( '/' ) ;
1189
+ var rootId = request . searchParams . get ( 'rootId' ) || self . props . defaultRootId ;
1190
+ return _await$1 ( gd . uploadByPath ( parent , name , fileBody , rootId ) , function ( _gd$uploadByPath ) {
1191
+ return new Response ( JSON . stringify ( _gd$uploadByPath ) , {
1192
+ headers : {
1193
+ 'Content-Type' : 'application/json'
1194
+ }
1195
+ } ) ;
1184
1196
} ) ;
1185
1197
} ) ;
1186
1198
} ) ;
1187
1199
1188
- function _empty ( ) { }
1200
+ function _invoke ( body , then ) {
1201
+ var result = body ( ) ;
1202
+
1203
+ if ( result && result . then ) {
1204
+ return result . then ( then ) ;
1205
+ }
1206
+
1207
+ return then ( result ) ;
1208
+ }
1189
1209
1190
1210
var onPost = _async ( function ( request ) {
1191
1211
var path = request . pathname ;
@@ -1228,13 +1248,7 @@ self.props = {
1228
1248
}
1229
1249
} ) ;
1230
1250
1231
- function _invokeIgnored ( body ) {
1232
- var result = body ( ) ;
1233
-
1234
- if ( result && result . then ) {
1235
- return result . then ( _empty ) ;
1236
- }
1237
- }
1251
+ function _empty ( ) { }
1238
1252
1239
1253
var onGet = _async ( function ( request ) {
1240
1254
var path = request . pathname ;
@@ -1293,14 +1307,12 @@ self.props = {
1293
1307
}
1294
1308
} ) ;
1295
1309
1296
- function _invoke ( body , then ) {
1310
+ function _invokeIgnored ( body ) {
1297
1311
var result = body ( ) ;
1298
1312
1299
1313
if ( result && result . then ) {
1300
- return result . then ( then ) ;
1314
+ return result . then ( _empty ) ;
1301
1315
}
1302
-
1303
- return then ( result ) ;
1304
1316
}
1305
1317
1306
1318
var gd = new GoogleDrive ( self . props ) ;
0 commit comments