|
1
|
-
|
|
|
|
2
|
import 'dart:convert';
|
1
|
import 'dart:convert';
|
|
3
|
import 'dart:io';
|
2
|
import 'dart:io';
|
|
4
|
|
3
|
|
|
@@ -30,7 +29,6 @@ enum UploadType { |
|
@@ -30,7 +29,6 @@ enum UploadType { |
|
30
|
WineManageType, //新建存酒
|
29
|
WineManageType, //新建存酒
|
|
31
|
CouponDishType, //新建优惠券菜品券图片
|
30
|
CouponDishType, //新建优惠券菜品券图片
|
|
32
|
RemarkImagesType // 订座详情备注图片
|
31
|
RemarkImagesType // 订座详情备注图片
|
|
33
|
-
|
|
|
|
34
|
}
|
32
|
}
|
|
35
|
|
33
|
|
|
36
|
class UploadImageUtil {
|
34
|
class UploadImageUtil {
|
|
@@ -133,195 +131,202 @@ class UploadImageUtil { |
|
@@ -133,195 +131,202 @@ class UploadImageUtil { |
|
133
|
}
|
131
|
}
|
|
134
|
print('开始上传文件');
|
132
|
print('开始上传文件');
|
|
135
|
|
133
|
|
|
136
|
- storage.putFile(
|
134
|
+ String? mimeType = Utils.getMimeType(selectedFile.path);
|
|
|
|
135
|
+ print(mimeType);
|
|
|
|
136
|
+
|
|
|
|
137
|
+ String imageName = Utils.getImageNameByDateTime(selectedFile.path);
|
|
|
|
138
|
+ print(imageName);
|
|
|
|
139
|
+
|
|
|
|
140
|
+ storage
|
|
|
|
141
|
+ .putFile(
|
|
137
|
selectedFile,
|
142
|
selectedFile,
|
|
138
|
usedToken,
|
143
|
usedToken,
|
|
139
|
options: PutOptions(
|
144
|
options: PutOptions(
|
|
140
|
// forceBySingle:
|
145
|
// forceBySingle:
|
|
141
|
- key: key,
|
146
|
+ key: imageName,
|
|
|
|
147
|
+ mimeType: mimeType,
|
|
142
|
partSize: partSize,
|
148
|
partSize: partSize,
|
|
143
|
controller: putController,
|
149
|
controller: putController,
|
|
144
|
),
|
150
|
),
|
|
145
|
)
|
151
|
)
|
|
146
|
- .then((PutResponse response) {
|
|
|
|
147
|
- print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
|
|
|
|
148
|
- print('------------------------');
|
|
|
|
149
|
- String imgUrl = uploadImageProvider.qiniuInfoSunModel!.domain! +
|
|
|
|
150
|
- '/' +
|
|
|
|
151
|
- response.rawData['key'];
|
|
|
|
152
|
- if (uploadType == UploadType.StoreFrontUploadType) {
|
|
|
|
153
|
- //门头
|
|
|
|
154
|
- uploadImageProvider.imageListFront[index].process = 1;
|
|
|
|
155
|
- uploadImageProvider.imageListFront[index].qiniuUrl = imgUrl;
|
|
|
|
156
|
- } else if (uploadType == UploadType.EnvironmentUploadType) {
|
|
|
|
157
|
- uploadImageProvider.imageListDenvironment[index].process = 1;
|
|
|
|
158
|
- uploadImageProvider.imageListDenvironment[index].qiniuUrl = imgUrl;
|
|
|
|
159
|
- } else if (uploadType == UploadType.ConsumptionUploadType) {
|
|
|
|
160
|
- //消费清单
|
|
|
|
161
|
- uploadImageProvider.imageList[index].process = 1;
|
|
|
|
162
|
- uploadImageProvider.imageList[index].qiniuUrl = imgUrl;
|
|
|
|
163
|
- callback!();
|
|
|
|
164
|
- } else if (uploadType == UploadType.TableManagerType) {
|
|
|
|
165
|
- //桌面照片管理
|
|
|
|
166
|
- uploadImageProvider.tableImageList[index].process = 1;
|
|
|
|
167
|
- uploadImageProvider.tableImageList[index].qiniuUrl = imgUrl;
|
|
|
|
168
|
- uploadImageProvider.tableImageList[index].isUpload = false;
|
|
|
|
169
|
- uploadImageProvider.countUpload++;
|
|
|
|
170
|
- if (uploadImageProvider.countUpload == countAll) {
|
|
|
|
171
|
- //所有图片上传完成,可以绑定桌位
|
|
|
|
172
|
- uploadImageProvider.countUpload = 0;
|
|
|
|
173
|
- callback!();
|
|
|
|
174
|
- }
|
|
|
|
175
|
- } else if (uploadType == UploadType.FeastRemarkType) {
|
|
|
|
176
|
- //宴会备注---意向
|
|
|
|
177
|
- uploadImageProvider.feastRemarkImageList[index].process = 1;
|
|
|
|
178
|
- uploadImageProvider.feastRemarkImageList[index].qiniuUrl = imgUrl;
|
|
|
|
179
|
- callback!();
|
|
|
|
180
|
- } else if (uploadType == UploadType.FeastRemarkXtType) {
|
|
|
|
181
|
- //宴会备注---选台
|
|
|
|
182
|
- feastRemarkXtImageList![index].process = 1;
|
|
|
|
183
|
- feastRemarkXtImageList[index].qiniuUrl = imgUrl;
|
|
|
|
184
|
- callback!();
|
|
|
|
185
|
- } else if (uploadType == UploadType.FeastRemarkDjType) {
|
|
|
|
186
|
- //宴会备注---订金
|
|
|
|
187
|
- uploadImageProvider.feastRemarkDjImageList[index].process = 1;
|
|
|
|
188
|
- uploadImageProvider.feastRemarkDjImageList[index].qiniuUrl = imgUrl;
|
|
|
|
189
|
- callback!();
|
|
|
|
190
|
- } else if (uploadType == UploadType.FeastRemarkContractType) {
|
|
|
|
191
|
- //宴会备注 ---合同
|
|
|
|
192
|
- uploadImageProvider.feastRemarkContractImageList[index].process = 1;
|
|
|
|
193
|
- uploadImageProvider.feastRemarkContractImageList[index].qiniuUrl =
|
|
|
|
194
|
- imgUrl;
|
|
|
|
195
|
- callback!();
|
|
|
|
196
|
- } else if (uploadType == UploadType.FeastRemarkInvoiceType) {
|
|
|
|
197
|
- //宴会备注 ---发票
|
|
|
|
198
|
- uploadImageProvider.feastRemarkInvoiceImageList[index].process = 1;
|
|
|
|
199
|
- uploadImageProvider.feastRemarkInvoiceImageList[index].qiniuUrl =
|
|
|
|
200
|
- imgUrl;
|
|
|
|
201
|
- callback!();
|
|
|
|
202
|
- } else if (uploadType == UploadType.InvitationStoreType) {
|
|
|
|
203
|
- //宴会备注 ---发票
|
|
|
|
204
|
- uploadImageProvider.feastRemarkInvoiceImageList[index].process = 1;
|
|
|
|
205
|
- uploadImageProvider.feastRemarkInvoiceImageList[index].qiniuUrl =
|
|
|
|
206
|
- imgUrl;
|
|
|
|
207
|
- } else if (uploadType == UploadType.WineManageType) {
|
|
|
|
208
|
- //新建存酒
|
|
|
|
209
|
- imageList![index].process = 1;
|
|
|
|
210
|
- imageList[index].qiniuUrl = imgUrl;
|
152
|
+ .then((PutResponse response) {
|
|
|
|
153
|
+ print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
|
|
|
|
154
|
+ print('------------------------');
|
|
|
|
155
|
+ String imgUrl = uploadImageProvider.qiniuInfoSunModel!.domain! +
|
|
|
|
156
|
+ '/' +
|
|
|
|
157
|
+ response.rawData['key'];
|
|
|
|
158
|
+ if (uploadType == UploadType.StoreFrontUploadType) {
|
|
|
|
159
|
+ //门头
|
|
|
|
160
|
+ uploadImageProvider.imageListFront[index].process = 1;
|
|
|
|
161
|
+ uploadImageProvider.imageListFront[index].qiniuUrl = imgUrl;
|
|
|
|
162
|
+ } else if (uploadType == UploadType.EnvironmentUploadType) {
|
|
|
|
163
|
+ uploadImageProvider.imageListDenvironment[index].process = 1;
|
|
|
|
164
|
+ uploadImageProvider.imageListDenvironment[index].qiniuUrl = imgUrl;
|
|
|
|
165
|
+ } else if (uploadType == UploadType.ConsumptionUploadType) {
|
|
|
|
166
|
+ //消费清单
|
|
|
|
167
|
+ uploadImageProvider.imageList[index].process = 1;
|
|
|
|
168
|
+ uploadImageProvider.imageList[index].qiniuUrl = imgUrl;
|
|
|
|
169
|
+ callback!();
|
|
|
|
170
|
+ } else if (uploadType == UploadType.TableManagerType) {
|
|
|
|
171
|
+ //桌面照片管理
|
|
|
|
172
|
+ uploadImageProvider.tableImageList[index].process = 1;
|
|
|
|
173
|
+ uploadImageProvider.tableImageList[index].qiniuUrl = imgUrl;
|
|
|
|
174
|
+ uploadImageProvider.tableImageList[index].isUpload = false;
|
|
|
|
175
|
+ uploadImageProvider.countUpload++;
|
|
|
|
176
|
+ if (uploadImageProvider.countUpload == countAll) {
|
|
|
|
177
|
+ //所有图片上传完成,可以绑定桌位
|
|
|
|
178
|
+ uploadImageProvider.countUpload = 0;
|
|
211
|
callback!();
|
179
|
callback!();
|
|
212
|
- } else if (uploadType == UploadType.CouponDishType) {
|
|
|
|
213
|
- //新建优惠券
|
|
|
|
214
|
- imageList![index].process = 1;
|
|
|
|
215
|
- imageList[index].qiniuUrl = imgUrl;
|
180
|
+ }
|
|
|
|
181
|
+ } else if (uploadType == UploadType.FeastRemarkType) {
|
|
|
|
182
|
+ //宴会备注---意向
|
|
|
|
183
|
+ uploadImageProvider.feastRemarkImageList[index].process = 1;
|
|
|
|
184
|
+ uploadImageProvider.feastRemarkImageList[index].qiniuUrl = imgUrl;
|
|
|
|
185
|
+ callback!();
|
|
|
|
186
|
+ } else if (uploadType == UploadType.FeastRemarkXtType) {
|
|
|
|
187
|
+ //宴会备注---选台
|
|
|
|
188
|
+ feastRemarkXtImageList![index].process = 1;
|
|
|
|
189
|
+ feastRemarkXtImageList[index].qiniuUrl = imgUrl;
|
|
|
|
190
|
+ callback!();
|
|
|
|
191
|
+ } else if (uploadType == UploadType.FeastRemarkDjType) {
|
|
|
|
192
|
+ //宴会备注---订金
|
|
|
|
193
|
+ uploadImageProvider.feastRemarkDjImageList[index].process = 1;
|
|
|
|
194
|
+ uploadImageProvider.feastRemarkDjImageList[index].qiniuUrl = imgUrl;
|
|
|
|
195
|
+ callback!();
|
|
|
|
196
|
+ } else if (uploadType == UploadType.FeastRemarkContractType) {
|
|
|
|
197
|
+ //宴会备注 ---合同
|
|
|
|
198
|
+ uploadImageProvider.feastRemarkContractImageList[index].process = 1;
|
|
|
|
199
|
+ uploadImageProvider.feastRemarkContractImageList[index].qiniuUrl =
|
|
|
|
200
|
+ imgUrl;
|
|
|
|
201
|
+ callback!();
|
|
|
|
202
|
+ } else if (uploadType == UploadType.FeastRemarkInvoiceType) {
|
|
|
|
203
|
+ //宴会备注 ---发票
|
|
|
|
204
|
+ uploadImageProvider.feastRemarkInvoiceImageList[index].process = 1;
|
|
|
|
205
|
+ uploadImageProvider.feastRemarkInvoiceImageList[index].qiniuUrl =
|
|
|
|
206
|
+ imgUrl;
|
|
|
|
207
|
+ callback!();
|
|
|
|
208
|
+ } else if (uploadType == UploadType.InvitationStoreType) {
|
|
|
|
209
|
+ //宴会备注 ---发票
|
|
|
|
210
|
+ uploadImageProvider.feastRemarkInvoiceImageList[index].process = 1;
|
|
|
|
211
|
+ uploadImageProvider.feastRemarkInvoiceImageList[index].qiniuUrl =
|
|
|
|
212
|
+ imgUrl;
|
|
|
|
213
|
+ } else if (uploadType == UploadType.WineManageType) {
|
|
|
|
214
|
+ //新建存酒
|
|
|
|
215
|
+ imageList![index].process = 1;
|
|
|
|
216
|
+ imageList[index].qiniuUrl = imgUrl;
|
|
|
|
217
|
+ callback!();
|
|
|
|
218
|
+ } else if (uploadType == UploadType.CouponDishType) {
|
|
|
|
219
|
+ //新建优惠券
|
|
|
|
220
|
+ imageList![index].process = 1;
|
|
|
|
221
|
+ imageList[index].qiniuUrl = imgUrl;
|
|
|
|
222
|
+ callback!();
|
|
|
|
223
|
+ } else if (uploadType == UploadType.RemarkImagesType) {
|
|
|
|
224
|
+ //备注图片
|
|
|
|
225
|
+ imageList![index].process = 1;
|
|
|
|
226
|
+ imageList[index].qiniuUrl = imgUrl;
|
|
|
|
227
|
+ imageList[index].isUpload = false;
|
|
|
|
228
|
+ uploadImageProvider.countUpload++;
|
|
|
|
229
|
+ if (uploadImageProvider.countUpload == countAll) {
|
|
|
|
230
|
+ //所有图片上传完成,可以绑定备注图片
|
|
|
|
231
|
+ uploadImageProvider.countUpload = 0;
|
|
216
|
callback!();
|
232
|
callback!();
|
|
217
|
- } else if (uploadType == UploadType.RemarkImagesType) {
|
|
|
|
218
|
- //备注图片
|
|
|
|
219
|
- imageList![index].process = 1;
|
|
|
|
220
|
- imageList[index].qiniuUrl = imgUrl;
|
|
|
|
221
|
- imageList[index].isUpload = false;
|
|
|
|
222
|
- uploadImageProvider.countUpload++;
|
|
|
|
223
|
- if (uploadImageProvider.countUpload == countAll) {
|
|
|
|
224
|
- //所有图片上传完成,可以绑定备注图片
|
|
|
|
225
|
- uploadImageProvider.countUpload = 0;
|
|
|
|
226
|
- callback!();
|
|
|
|
227
|
- }
|
|
|
|
228
|
}
|
233
|
}
|
|
|
|
234
|
+ }
|
|
229
|
|
235
|
|
|
230
|
- // 取消当前任务
|
|
|
|
231
|
- // putController.cancel();
|
|
|
|
232
|
- // _image
|
|
|
|
233
|
- uploadImageProvider.notifyListeners();
|
|
|
|
234
|
- })
|
|
|
|
235
|
- .catchError((dynamic error) {
|
|
|
|
236
|
- if (uploadType == UploadType.StoreFrontUploadType) {
|
|
|
|
237
|
- //门头
|
|
|
|
238
|
- uploadImageProvider.imageListFront.removeAt(index);
|
|
|
|
239
|
- } else if (uploadType == UploadType.EnvironmentUploadType) {
|
|
|
|
240
|
- uploadImageProvider.imageListDenvironment.removeAt(index);
|
|
|
|
241
|
- } else if (uploadType == UploadType.ConsumptionUploadType) {
|
|
|
|
242
|
- //消费清单
|
|
|
|
243
|
- uploadImageProvider.imageList.removeAt(index);
|
|
|
|
244
|
- } else if (uploadType == UploadType.TableManagerType) {
|
|
|
|
245
|
- //桌面照片管理
|
|
|
|
246
|
- uploadImageProvider.tableImageList.removeAt(index);
|
|
|
|
247
|
- } else if (uploadType == UploadType.FeastRemarkType) {
|
|
|
|
248
|
- //宴会备注---意向
|
|
|
|
249
|
- uploadImageProvider.feastRemarkImageList.removeAt(index);
|
|
|
|
250
|
- } else if (uploadType == UploadType.FeastRemarkXtType) {
|
|
|
|
251
|
- //宴会备注---选台
|
|
|
|
252
|
- feastRemarkXtImageList!.removeAt(index);
|
|
|
|
253
|
- } else if (uploadType == UploadType.FeastRemarkDjType) {
|
|
|
|
254
|
- //宴会备注---订金
|
|
|
|
255
|
- uploadImageProvider.feastRemarkDjImageList.removeAt(index);
|
|
|
|
256
|
- } else if (uploadType == UploadType.FeastRemarkContractType) {
|
|
|
|
257
|
- //宴会备注 ---合同
|
|
|
|
258
|
- uploadImageProvider.feastRemarkContractImageList.removeAt(index);
|
|
|
|
259
|
- } else if (uploadType == UploadType.FeastRemarkInvoiceType) {
|
|
|
|
260
|
- //宴会备注 ---发票
|
|
|
|
261
|
- uploadImageProvider.feastRemarkInvoiceImageList.removeAt(index);
|
|
|
|
262
|
- } else if (uploadType == UploadType.InvitationStoreType) {
|
|
|
|
263
|
- //宴会备注 ---发票
|
|
|
|
264
|
- uploadImageProvider.feastRemarkInvoiceImageList.removeAt(index);
|
|
|
|
265
|
- } else if (uploadType == UploadType.WineManageType) {
|
|
|
|
266
|
- //新建存酒
|
|
|
|
267
|
- imageList!.removeAt(index);
|
|
|
|
268
|
- } else if (uploadType == UploadType.CouponDishType) {
|
|
|
|
269
|
- //新建优惠券
|
|
|
|
270
|
- imageList!.removeAt(index);
|
|
|
|
271
|
- } else if (uploadType == UploadType.RemarkImagesType) {
|
|
|
|
272
|
- //图片备注
|
|
|
|
273
|
- imageList!.removeAt(index);
|
|
|
|
274
|
- }
|
236
|
+ // 取消当前任务
|
|
|
|
237
|
+ // putController.cancel();
|
|
|
|
238
|
+ // _image
|
|
|
|
239
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
240
|
+ }).catchError((dynamic error) {
|
|
|
|
241
|
+ if (uploadType == UploadType.StoreFrontUploadType) {
|
|
|
|
242
|
+ //门头
|
|
|
|
243
|
+ uploadImageProvider.imageListFront.removeAt(index);
|
|
|
|
244
|
+ } else if (uploadType == UploadType.EnvironmentUploadType) {
|
|
|
|
245
|
+ uploadImageProvider.imageListDenvironment.removeAt(index);
|
|
|
|
246
|
+ } else if (uploadType == UploadType.ConsumptionUploadType) {
|
|
|
|
247
|
+ //消费清单
|
|
|
|
248
|
+ uploadImageProvider.imageList.removeAt(index);
|
|
|
|
249
|
+ } else if (uploadType == UploadType.TableManagerType) {
|
|
|
|
250
|
+ //桌面照片管理
|
|
|
|
251
|
+ uploadImageProvider.tableImageList.removeAt(index);
|
|
|
|
252
|
+ } else if (uploadType == UploadType.FeastRemarkType) {
|
|
|
|
253
|
+ //宴会备注---意向
|
|
|
|
254
|
+ uploadImageProvider.feastRemarkImageList.removeAt(index);
|
|
|
|
255
|
+ } else if (uploadType == UploadType.FeastRemarkXtType) {
|
|
|
|
256
|
+ //宴会备注---选台
|
|
|
|
257
|
+ feastRemarkXtImageList!.removeAt(index);
|
|
|
|
258
|
+ } else if (uploadType == UploadType.FeastRemarkDjType) {
|
|
|
|
259
|
+ //宴会备注---订金
|
|
|
|
260
|
+ uploadImageProvider.feastRemarkDjImageList.removeAt(index);
|
|
|
|
261
|
+ } else if (uploadType == UploadType.FeastRemarkContractType) {
|
|
|
|
262
|
+ //宴会备注 ---合同
|
|
|
|
263
|
+ uploadImageProvider.feastRemarkContractImageList.removeAt(index);
|
|
|
|
264
|
+ } else if (uploadType == UploadType.FeastRemarkInvoiceType) {
|
|
|
|
265
|
+ //宴会备注 ---发票
|
|
|
|
266
|
+ uploadImageProvider.feastRemarkInvoiceImageList.removeAt(index);
|
|
|
|
267
|
+ } else if (uploadType == UploadType.InvitationStoreType) {
|
|
|
|
268
|
+ //宴会备注 ---发票
|
|
|
|
269
|
+ uploadImageProvider.feastRemarkInvoiceImageList.removeAt(index);
|
|
|
|
270
|
+ } else if (uploadType == UploadType.WineManageType) {
|
|
|
|
271
|
+ //新建存酒
|
|
|
|
272
|
+ imageList!.removeAt(index);
|
|
|
|
273
|
+ } else if (uploadType == UploadType.CouponDishType) {
|
|
|
|
274
|
+ //新建优惠券
|
|
|
|
275
|
+ imageList!.removeAt(index);
|
|
|
|
276
|
+ } else if (uploadType == UploadType.RemarkImagesType) {
|
|
|
|
277
|
+ //图片备注
|
|
|
|
278
|
+ imageList!.removeAt(index);
|
|
|
|
279
|
+ }
|
|
275
|
|
280
|
|
|
276
|
- // 取消当前任务
|
|
|
|
277
|
- putController.cancel();
|
|
|
|
278
|
- uploadImageProvider.notifyListeners();
|
|
|
|
279
|
- if (error is StorageError) {
|
|
|
|
280
|
- switch (error.type) {
|
|
|
|
281
|
- case StorageErrorType.CONNECT_TIMEOUT:
|
|
|
|
282
|
- Utils.showToast('发生错误: 连接超时');
|
|
|
|
283
|
- break;
|
|
|
|
284
|
- case StorageErrorType.SEND_TIMEOUT:
|
|
|
|
285
|
- print('发生错误: 发送数据超时');
|
|
|
|
286
|
- Utils.showToast('发生错误: 发送数据超时');
|
|
|
|
287
|
- break;
|
|
|
|
288
|
- case StorageErrorType.RECEIVE_TIMEOUT:
|
|
|
|
289
|
- print('发生错误: 响应数据超时');
|
|
|
|
290
|
- Utils.showToast('发生错误: 响应数据超时');
|
|
|
|
291
|
- break;
|
|
|
|
292
|
- case StorageErrorType.RESPONSE:
|
|
|
|
293
|
- print('发生错误: ${error.message}');
|
|
|
|
294
|
- Utils.showToast('发生错误: ${error.message}');
|
|
|
|
295
|
- // Utils.showToast('发生错误000: ${error}');
|
|
|
|
296
|
- // Utils.showToast('发生错误000: ${error.code}');
|
|
|
|
297
|
- // Utils.showToast('发生错误000: ${error.message}');
|
|
|
|
298
|
- break;
|
|
|
|
299
|
- case StorageErrorType.CANCEL:
|
|
|
|
300
|
- print('发生错误: 请求取消');
|
|
|
|
301
|
- Utils.showToast('发生错误: 请求取消');
|
|
|
|
302
|
- break;
|
|
|
|
303
|
- case StorageErrorType.UNKNOWN:
|
|
|
|
304
|
- print('发生错误: ');
|
|
|
|
305
|
- Utils.showToast('发生错误: 未知错误');
|
|
|
|
306
|
- break;
|
|
|
|
307
|
- case StorageErrorType.NO_AVAILABLE_HOST:
|
|
|
|
308
|
- print('发生错误: 无可用 Host');
|
|
|
|
309
|
- Utils.showToast('发生错误: 无可用 Host');
|
|
|
|
310
|
- break;
|
|
|
|
311
|
- case StorageErrorType.IN_PROGRESS:
|
|
|
|
312
|
- print('发生错误: 已在队列中');
|
|
|
|
313
|
- Utils.showToast('发生错误: 已在队列中');
|
|
|
|
314
|
- break;
|
|
|
|
315
|
- // case StorageErrorType.NO_AVAILABLE_REGION:
|
|
|
|
316
|
- // TODO: Handle this case.
|
|
|
|
317
|
- }
|
|
|
|
318
|
- } else {
|
|
|
|
319
|
- print('发生错误: ${error.toString()}');
|
|
|
|
320
|
- Utils.showToast('发生错误: ${error.toString()}');
|
281
|
+ // 取消当前任务
|
|
|
|
282
|
+ putController.cancel();
|
|
|
|
283
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
284
|
+ if (error is StorageError) {
|
|
|
|
285
|
+ switch (error.type) {
|
|
|
|
286
|
+ case StorageErrorType.CONNECT_TIMEOUT:
|
|
|
|
287
|
+ Utils.showToast('发生错误: 连接超时');
|
|
|
|
288
|
+ break;
|
|
|
|
289
|
+ case StorageErrorType.SEND_TIMEOUT:
|
|
|
|
290
|
+ print('发生错误: 发送数据超时');
|
|
|
|
291
|
+ Utils.showToast('发生错误: 发送数据超时');
|
|
|
|
292
|
+ break;
|
|
|
|
293
|
+ case StorageErrorType.RECEIVE_TIMEOUT:
|
|
|
|
294
|
+ print('发生错误: 响应数据超时');
|
|
|
|
295
|
+ Utils.showToast('发生错误: 响应数据超时');
|
|
|
|
296
|
+ break;
|
|
|
|
297
|
+ case StorageErrorType.RESPONSE:
|
|
|
|
298
|
+ print('发生错误: ${error.message}');
|
|
|
|
299
|
+ Utils.showToast('发生错误: ${error.message}');
|
|
|
|
300
|
+ // Utils.showToast('发生错误000: ${error}');
|
|
|
|
301
|
+ // Utils.showToast('发生错误000: ${error.code}');
|
|
|
|
302
|
+ // Utils.showToast('发生错误000: ${error.message}');
|
|
|
|
303
|
+ break;
|
|
|
|
304
|
+ case StorageErrorType.CANCEL:
|
|
|
|
305
|
+ print('发生错误: 请求取消');
|
|
|
|
306
|
+ Utils.showToast('发生错误: 请求取消');
|
|
|
|
307
|
+ break;
|
|
|
|
308
|
+ case StorageErrorType.UNKNOWN:
|
|
|
|
309
|
+ print('发生错误: ');
|
|
|
|
310
|
+ Utils.showToast('发生错误: 未知错误');
|
|
|
|
311
|
+ break;
|
|
|
|
312
|
+ case StorageErrorType.NO_AVAILABLE_HOST:
|
|
|
|
313
|
+ print('发生错误: 无可用 Host');
|
|
|
|
314
|
+ Utils.showToast('发生错误: 无可用 Host');
|
|
|
|
315
|
+ break;
|
|
|
|
316
|
+ case StorageErrorType.IN_PROGRESS:
|
|
|
|
317
|
+ print('发生错误: 已在队列中');
|
|
|
|
318
|
+ Utils.showToast('发生错误: 已在队列中');
|
|
|
|
319
|
+ break;
|
|
|
|
320
|
+ // case StorageErrorType.NO_AVAILABLE_REGION:
|
|
|
|
321
|
+ // TODO: Handle this case.
|
|
321
|
}
|
322
|
}
|
|
|
|
323
|
+ } else {
|
|
|
|
324
|
+ print('发生错误: ${error.toString()}');
|
|
|
|
325
|
+ Utils.showToast('发生错误: ${error.toString()}');
|
|
|
|
326
|
+ }
|
|
322
|
|
327
|
|
|
323
|
- print('------------------------');
|
|
|
|
324
|
- });
|
328
|
+ print('------------------------');
|
|
|
|
329
|
+ });
|
|
325
|
}
|
330
|
}
|
|
326
|
|
331
|
|
|
327
|
///上传到七牛云
|
332
|
///上传到七牛云
|
|
@@ -342,7 +347,8 @@ class UploadImageUtil { |
|
@@ -342,7 +347,8 @@ class UploadImageUtil { |
|
342
|
// 添加整体进度监听
|
347
|
// 添加整体进度监听
|
|
343
|
putController.addProgressListener((percent) {
|
348
|
putController.addProgressListener((percent) {
|
|
344
|
print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}');
|
349
|
print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}');
|
|
345
|
- UploadImgModel imgModel = uploadImageProvider.getDynamicValue('${index}')!;
|
350
|
+ UploadImgModel imgModel =
|
|
|
|
351
|
+ uploadImageProvider.getDynamicValue('${index}')!;
|
|
346
|
imgModel.process = percent;
|
352
|
imgModel.process = percent;
|
|
347
|
uploadImageProvider.notifyListeners();
|
353
|
uploadImageProvider.notifyListeners();
|
|
348
|
});
|
354
|
});
|
|
@@ -360,89 +366,98 @@ class UploadImageUtil { |
|
@@ -360,89 +366,98 @@ class UploadImageUtil { |
|
360
|
print('token 不能为空');
|
366
|
print('token 不能为空');
|
|
361
|
return;
|
367
|
return;
|
|
362
|
}
|
368
|
}
|
|
363
|
- print('开始上传文件');
|
|
|
|
364
|
- storage.putFile(
|
|
|
|
365
|
- selectedFile!,
|
369
|
+
|
|
|
|
370
|
+ print('开始上传文件${key}');
|
|
|
|
371
|
+
|
|
|
|
372
|
+ String? mimeType = Utils.getMimeType(selectedFile!.path);
|
|
|
|
373
|
+ print(mimeType);
|
|
|
|
374
|
+
|
|
|
|
375
|
+ String imageName = Utils.getImageNameByDateTime(selectedFile.path);
|
|
|
|
376
|
+ print(imageName);
|
|
|
|
377
|
+
|
|
|
|
378
|
+ storage
|
|
|
|
379
|
+ .putFile(
|
|
|
|
380
|
+ selectedFile,
|
|
366
|
usedToken,
|
381
|
usedToken,
|
|
367
|
options: PutOptions(
|
382
|
options: PutOptions(
|
|
368
|
- key: key,
|
383
|
+ key: imageName,
|
|
|
|
384
|
+ mimeType: mimeType,
|
|
369
|
partSize: partSize,
|
385
|
partSize: partSize,
|
|
370
|
controller: putController,
|
386
|
controller: putController,
|
|
371
|
),
|
387
|
),
|
|
372
|
)
|
388
|
)
|
|
373
|
- .then((PutResponse response) {
|
|
|
|
374
|
- print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
|
|
|
|
375
|
- print('------------------------');
|
|
|
|
376
|
- String imgUrl = uploadImageProvider.qiniuInfoSunModel!.domain! +
|
|
|
|
377
|
- '/' +
|
|
|
|
378
|
- response.rawData['key'];
|
|
|
|
379
|
-
|
|
|
|
380
|
- // 取消当前任务
|
|
|
|
381
|
- // putController.cancel();
|
|
|
|
382
|
- UploadImgModel imgModel =
|
|
|
|
383
|
- uploadImageProvider.getDynamicValue('${index}')!;
|
|
|
|
384
|
- imgModel.process = 1;
|
|
|
|
385
|
- imgModel.qiniuUrl = imgUrl;
|
|
|
|
386
|
- imgModel.file = null;
|
|
|
|
387
|
- uploadImageProvider.notifyListeners();
|
|
|
|
388
|
- callback();
|
|
|
|
389
|
- })
|
|
|
|
390
|
- .catchError((dynamic error) {
|
|
|
|
391
|
- UploadImgModel imgModel =
|
|
|
|
392
|
- uploadImageProvider.getDynamicValue('${index}')!;
|
|
|
|
393
|
- imgModel.process = 0;
|
|
|
|
394
|
- imgModel.qiniuUrl = null;
|
|
|
|
395
|
- imgModel.file = null;
|
|
|
|
396
|
- uploadImageProvider.notifyListeners();
|
389
|
+ .then((PutResponse response) {
|
|
|
|
390
|
+ print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
|
|
|
|
391
|
+ print('------------------------');
|
|
|
|
392
|
+ String imgUrl = uploadImageProvider.qiniuInfoSunModel!.domain! +
|
|
|
|
393
|
+ '/' +
|
|
|
|
394
|
+ response.rawData['key'];
|
|
397
|
|
395
|
|
|
398
|
- // 取消当前任务
|
|
|
|
399
|
- putController.cancel();
|
|
|
|
400
|
- uploadImageProvider.notifyListeners();
|
|
|
|
401
|
- if (error is StorageError) {
|
|
|
|
402
|
- switch (error.type) {
|
|
|
|
403
|
- case StorageErrorType.CONNECT_TIMEOUT:
|
|
|
|
404
|
- Utils.showToast('发生错误: 连接超时');
|
|
|
|
405
|
- break;
|
|
|
|
406
|
- case StorageErrorType.SEND_TIMEOUT:
|
|
|
|
407
|
- print('发生错误: 发送数据超时');
|
|
|
|
408
|
- Utils.showToast('发生错误: 发送数据超时');
|
|
|
|
409
|
- break;
|
|
|
|
410
|
- case StorageErrorType.RECEIVE_TIMEOUT:
|
|
|
|
411
|
- print('发生错误: 响应数据超时');
|
|
|
|
412
|
- Utils.showToast('发生错误: 响应数据超时');
|
|
|
|
413
|
- break;
|
|
|
|
414
|
- case StorageErrorType.RESPONSE:
|
|
|
|
415
|
- print('发生错误: ${error.message}');
|
|
|
|
416
|
- // Utils.showToast('发生错误000: ${error}');
|
|
|
|
417
|
- // Utils.showToast('发生错误000: ${error.code}');
|
|
|
|
418
|
- Utils.showToast('发生错误: ${error.message}');
|
|
|
|
419
|
- break;
|
|
|
|
420
|
- case StorageErrorType.CANCEL:
|
|
|
|
421
|
- print('发生错误: 请求取消');
|
|
|
|
422
|
- Utils.showToast('发生错误: 请求取消');
|
|
|
|
423
|
- break;
|
|
|
|
424
|
- case StorageErrorType.UNKNOWN:
|
|
|
|
425
|
- print('发生错误: ');
|
|
|
|
426
|
- Utils.showToast('发生错误: 未知错误');
|
|
|
|
427
|
- break;
|
|
|
|
428
|
- case StorageErrorType.NO_AVAILABLE_HOST:
|
|
|
|
429
|
- print('发生错误: 无可用 Host');
|
|
|
|
430
|
- Utils.showToast('发生错误: 无可用 Host');
|
|
|
|
431
|
- break;
|
|
|
|
432
|
- case StorageErrorType.IN_PROGRESS:
|
|
|
|
433
|
- print('发生错误: 已在队列中');
|
|
|
|
434
|
- Utils.showToast('发生错误: 已在队列中');
|
|
|
|
435
|
- break;
|
|
|
|
436
|
- // case StorageErrorType.NO_AVAILABLE_REGION:
|
|
|
|
437
|
- // TODO: Handle this case.
|
|
|
|
438
|
- }
|
|
|
|
439
|
- } else {
|
|
|
|
440
|
- print('发生错误: ${error.toString()}');
|
|
|
|
441
|
- Utils.showToast('发生错误: ${error.toString()}');
|
396
|
+ // 取消当前任务
|
|
|
|
397
|
+ // putController.cancel();
|
|
|
|
398
|
+ UploadImgModel imgModel =
|
|
|
|
399
|
+ uploadImageProvider.getDynamicValue('${index}')!;
|
|
|
|
400
|
+ imgModel.process = 1;
|
|
|
|
401
|
+ imgModel.qiniuUrl = imgUrl;
|
|
|
|
402
|
+ imgModel.file = null;
|
|
|
|
403
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
404
|
+ callback();
|
|
|
|
405
|
+ }).catchError((dynamic error) {
|
|
|
|
406
|
+ UploadImgModel imgModel =
|
|
|
|
407
|
+ uploadImageProvider.getDynamicValue('${index}')!;
|
|
|
|
408
|
+ imgModel.process = 0;
|
|
|
|
409
|
+ imgModel.qiniuUrl = null;
|
|
|
|
410
|
+ imgModel.file = null;
|
|
|
|
411
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
412
|
+
|
|
|
|
413
|
+ // 取消当前任务
|
|
|
|
414
|
+ putController.cancel();
|
|
|
|
415
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
416
|
+ if (error is StorageError) {
|
|
|
|
417
|
+ switch (error.type) {
|
|
|
|
418
|
+ case StorageErrorType.CONNECT_TIMEOUT:
|
|
|
|
419
|
+ Utils.showToast('发生错误: 连接超时');
|
|
|
|
420
|
+ break;
|
|
|
|
421
|
+ case StorageErrorType.SEND_TIMEOUT:
|
|
|
|
422
|
+ print('发生错误: 发送数据超时');
|
|
|
|
423
|
+ Utils.showToast('发生错误: 发送数据超时');
|
|
|
|
424
|
+ break;
|
|
|
|
425
|
+ case StorageErrorType.RECEIVE_TIMEOUT:
|
|
|
|
426
|
+ print('发生错误: 响应数据超时');
|
|
|
|
427
|
+ Utils.showToast('发生错误: 响应数据超时');
|
|
|
|
428
|
+ break;
|
|
|
|
429
|
+ case StorageErrorType.RESPONSE:
|
|
|
|
430
|
+ print('发生错误: ${error.message}');
|
|
|
|
431
|
+ // Utils.showToast('发生错误000: ${error}');
|
|
|
|
432
|
+ // Utils.showToast('发生错误000: ${error.code}');
|
|
|
|
433
|
+ Utils.showToast('发生错误: ${error.message}');
|
|
|
|
434
|
+ break;
|
|
|
|
435
|
+ case StorageErrorType.CANCEL:
|
|
|
|
436
|
+ print('发生错误: 请求取消');
|
|
|
|
437
|
+ Utils.showToast('发生错误: 请求取消');
|
|
|
|
438
|
+ break;
|
|
|
|
439
|
+ case StorageErrorType.UNKNOWN:
|
|
|
|
440
|
+ print('发生错误: ');
|
|
|
|
441
|
+ Utils.showToast('发生错误: 未知错误');
|
|
|
|
442
|
+ break;
|
|
|
|
443
|
+ case StorageErrorType.NO_AVAILABLE_HOST:
|
|
|
|
444
|
+ print('发生错误: 无可用 Host');
|
|
|
|
445
|
+ Utils.showToast('发生错误: 无可用 Host');
|
|
|
|
446
|
+ break;
|
|
|
|
447
|
+ case StorageErrorType.IN_PROGRESS:
|
|
|
|
448
|
+ print('发生错误: 已在队列中');
|
|
|
|
449
|
+ Utils.showToast('发生错误: 已在队列中');
|
|
|
|
450
|
+ break;
|
|
|
|
451
|
+ // case StorageErrorType.NO_AVAILABLE_REGION:
|
|
|
|
452
|
+ // TODO: Handle this case.
|
|
442
|
}
|
453
|
}
|
|
|
|
454
|
+ } else {
|
|
|
|
455
|
+ print('发生错误: ${error.toString()}');
|
|
|
|
456
|
+ Utils.showToast('发生错误: ${error.toString()}');
|
|
|
|
457
|
+ }
|
|
443
|
|
458
|
|
|
444
|
- print('------------------------');
|
|
|
|
445
|
- });
|
459
|
+ print('------------------------');
|
|
|
|
460
|
+ });
|
|
446
|
}
|
461
|
}
|
|
447
|
|
462
|
|
|
448
|
///上传到七牛云
|
463
|
///上传到七牛云
|
|
@@ -517,207 +532,214 @@ class UploadImageUtil { |
|
@@ -517,207 +532,214 @@ class UploadImageUtil { |
|
517
|
return;
|
532
|
return;
|
|
518
|
}
|
533
|
}
|
|
519
|
print('开始上传文件');
|
534
|
print('开始上传文件');
|
|
520
|
- storage.putFile(
|
535
|
+ String? mimeType = Utils.getMimeType(selectedFile.path);
|
|
|
|
536
|
+ print(mimeType);
|
|
|
|
537
|
+
|
|
|
|
538
|
+ String imageName = Utils.getImageNameByDateTime(selectedFile.path);
|
|
|
|
539
|
+ print(imageName);
|
|
|
|
540
|
+
|
|
|
|
541
|
+ storage
|
|
|
|
542
|
+ .putFile(
|
|
521
|
selectedFile,
|
543
|
selectedFile,
|
|
522
|
usedToken,
|
544
|
usedToken,
|
|
523
|
options: PutOptions(
|
545
|
options: PutOptions(
|
|
524
|
- key: key,
|
546
|
+ key: imageName,
|
|
|
|
547
|
+ mimeType: mimeType,
|
|
525
|
partSize: partSize,
|
548
|
partSize: partSize,
|
|
526
|
controller: putController,
|
549
|
controller: putController,
|
|
527
|
),
|
550
|
),
|
|
528
|
)
|
551
|
)
|
|
529
|
- .then((PutResponse response) {
|
|
|
|
530
|
- print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
|
|
|
|
531
|
- print('------------------------');
|
|
|
|
532
|
- String imgUrl = uploadImageProvider.qiniuInfoSunModel!.domain! +
|
|
|
|
533
|
- '/' +
|
|
|
|
534
|
- response.rawData['key'];
|
|
|
|
535
|
-
|
|
|
|
536
|
- // 取消当前任务
|
|
|
|
537
|
- // putController.cancel();
|
|
|
|
538
|
- if (index == 0) {
|
|
|
|
539
|
- uploadImageProvider.touxiang.process = 1;
|
|
|
|
540
|
- uploadImageProvider.touxiang.qiniuUrl = imgUrl;
|
|
|
|
541
|
- uploadImageProvider.touxiang.file = null;
|
|
|
|
542
|
- uploadImageProvider.notifyListeners();
|
|
|
|
543
|
- callback!();
|
|
|
|
544
|
- } else if (index == 1) {
|
|
|
|
545
|
- uploadImageProvider.erweima.process = 1;
|
|
|
|
546
|
- uploadImageProvider.erweima.qiniuUrl = imgUrl;
|
|
|
|
547
|
- uploadImageProvider.erweima.file = null;
|
|
|
|
548
|
- uploadImageProvider.notifyListeners();
|
|
|
|
549
|
- callback!();
|
|
|
|
550
|
- } else if (index == 2) {
|
|
|
|
551
|
- uploadImageProvider.mentou.process = 1;
|
|
|
|
552
|
- uploadImageProvider.mentou.qiniuUrl = imgUrl;
|
|
|
|
553
|
- uploadImageProvider.mentou.file = null;
|
|
|
|
554
|
- uploadImageProvider.notifyListeners();
|
|
|
|
555
|
- callback!();
|
|
|
|
556
|
- } else if (index == 3) {
|
|
|
|
557
|
- uploadImageProvider.dish.process = 1;
|
|
|
|
558
|
- uploadImageProvider.dish.qiniuUrl = imgUrl;
|
|
|
|
559
|
- uploadImageProvider.dish.file = null;
|
|
|
|
560
|
- uploadImageProvider.notifyListeners();
|
|
|
|
561
|
- callback!();
|
|
|
|
562
|
- } else if (index == 4) {
|
|
|
|
563
|
- uploadImageProvider.firstImage.process = 1;
|
|
|
|
564
|
- uploadImageProvider.firstImage.qiniuUrl = imgUrl;
|
|
|
|
565
|
- uploadImageProvider.firstImage.file = null;
|
|
|
|
566
|
- uploadImageProvider.notifyListeners();
|
|
|
|
567
|
- callback!();
|
|
|
|
568
|
- } else if (index == 5) {
|
|
|
|
569
|
- uploadImageProvider.storeImage1.process = 1;
|
|
|
|
570
|
- uploadImageProvider.storeImage1.qiniuUrl = imgUrl;
|
|
|
|
571
|
- uploadImageProvider.storeImage1.file = null;
|
|
|
|
572
|
- uploadImageProvider.notifyListeners();
|
|
|
|
573
|
- callback!();
|
|
|
|
574
|
- } else if (index == 6) {
|
|
|
|
575
|
- uploadImageProvider.storeImage2.process = 1;
|
|
|
|
576
|
- uploadImageProvider.storeImage2.qiniuUrl = imgUrl;
|
|
|
|
577
|
- uploadImageProvider.storeImage2.file = null;
|
|
|
|
578
|
- uploadImageProvider.notifyListeners();
|
|
|
|
579
|
- callback!();
|
|
|
|
580
|
- } else if (index == 7) {
|
|
|
|
581
|
- uploadImageProvider.storeImage3.process = 1;
|
|
|
|
582
|
- uploadImageProvider.storeImage3.qiniuUrl = imgUrl;
|
|
|
|
583
|
- uploadImageProvider.storeImage3.file = null;
|
|
|
|
584
|
- uploadImageProvider.notifyListeners();
|
|
|
|
585
|
- callback!();
|
|
|
|
586
|
- } else if (index == 8) {
|
|
|
|
587
|
- uploadImageProvider.storeImage4.process = 1;
|
|
|
|
588
|
- uploadImageProvider.storeImage4.qiniuUrl = imgUrl;
|
|
|
|
589
|
- uploadImageProvider.storeImage4.file = null;
|
|
|
|
590
|
- uploadImageProvider.notifyListeners();
|
|
|
|
591
|
- callback!();
|
|
|
|
592
|
- } else if (index == 9) {
|
|
|
|
593
|
- uploadImageProvider.logo.process = 1;
|
|
|
|
594
|
- uploadImageProvider.logo.qiniuUrl = imgUrl;
|
|
|
|
595
|
- uploadImageProvider.logo.file = null;
|
|
|
|
596
|
- uploadImageProvider.notifyListeners();
|
|
|
|
597
|
- callback!();
|
|
|
|
598
|
- } else if (index == 10) {
|
|
|
|
599
|
- uploadImageProvider.storeImage5.process = 1;
|
|
|
|
600
|
- uploadImageProvider.storeImage5.qiniuUrl = imgUrl;
|
|
|
|
601
|
- uploadImageProvider.storeImage5.file = null;
|
|
|
|
602
|
- uploadImageProvider.notifyListeners();
|
|
|
|
603
|
- callback!();
|
|
|
|
604
|
- } else if (index == 11) {
|
|
|
|
605
|
- uploadImageProvider.storeImage6.process = 1;
|
|
|
|
606
|
- uploadImageProvider.storeImage6.qiniuUrl = imgUrl;
|
|
|
|
607
|
- uploadImageProvider.storeImage6.file = null;
|
|
|
|
608
|
- uploadImageProvider.notifyListeners();
|
|
|
|
609
|
- callback!();
|
|
|
|
610
|
- }
|
|
|
|
611
|
- })
|
|
|
|
612
|
- .catchError((dynamic error) {
|
|
|
|
613
|
- if (index == 0) {
|
|
|
|
614
|
- uploadImageProvider.touxiang.process = 0;
|
|
|
|
615
|
- uploadImageProvider.touxiang.qiniuUrl = null;
|
|
|
|
616
|
- uploadImageProvider.touxiang.file = null;
|
|
|
|
617
|
- uploadImageProvider.notifyListeners();
|
|
|
|
618
|
- } else if (index == 1) {
|
|
|
|
619
|
- uploadImageProvider.erweima.process = 0;
|
|
|
|
620
|
- uploadImageProvider.erweima.qiniuUrl = null;
|
|
|
|
621
|
- uploadImageProvider.erweima.file = null;
|
|
|
|
622
|
- uploadImageProvider.notifyListeners();
|
|
|
|
623
|
- } else if (index == 2) {
|
|
|
|
624
|
- uploadImageProvider.mentou.process = 0;
|
|
|
|
625
|
- uploadImageProvider.mentou.qiniuUrl = null;
|
|
|
|
626
|
- uploadImageProvider.mentou.file = null;
|
|
|
|
627
|
- uploadImageProvider.notifyListeners();
|
|
|
|
628
|
- } else if (index == 3) {
|
|
|
|
629
|
- uploadImageProvider.dish.process = 0;
|
|
|
|
630
|
- uploadImageProvider.dish.qiniuUrl = null;
|
|
|
|
631
|
- uploadImageProvider.dish.file = null;
|
|
|
|
632
|
- uploadImageProvider.notifyListeners();
|
|
|
|
633
|
- } else if (index == 4) {
|
|
|
|
634
|
- uploadImageProvider.firstImage.process = 0;
|
|
|
|
635
|
- uploadImageProvider.firstImage.qiniuUrl = null;
|
|
|
|
636
|
- uploadImageProvider.firstImage.file = null;
|
|
|
|
637
|
- uploadImageProvider.notifyListeners();
|
|
|
|
638
|
- } else if (index == 5) {
|
|
|
|
639
|
- uploadImageProvider.storeImage1.process = 0;
|
|
|
|
640
|
- uploadImageProvider.storeImage1.qiniuUrl = null;
|
|
|
|
641
|
- uploadImageProvider.storeImage1.file = null;
|
|
|
|
642
|
- uploadImageProvider.notifyListeners();
|
|
|
|
643
|
- } else if (index == 6) {
|
|
|
|
644
|
- uploadImageProvider.storeImage2.process = 0;
|
|
|
|
645
|
- uploadImageProvider.storeImage2.qiniuUrl = null;
|
|
|
|
646
|
- uploadImageProvider.storeImage2.file = null;
|
|
|
|
647
|
- uploadImageProvider.notifyListeners();
|
|
|
|
648
|
- } else if (index == 7) {
|
|
|
|
649
|
- uploadImageProvider.storeImage3.process = 0;
|
|
|
|
650
|
- uploadImageProvider.storeImage3.qiniuUrl = null;
|
|
|
|
651
|
- uploadImageProvider.storeImage3.file = null;
|
|
|
|
652
|
- uploadImageProvider.notifyListeners();
|
|
|
|
653
|
- } else if (index == 8) {
|
|
|
|
654
|
- uploadImageProvider.storeImage4.process = 0;
|
|
|
|
655
|
- uploadImageProvider.storeImage4.qiniuUrl = null;
|
|
|
|
656
|
- uploadImageProvider.storeImage4.file = null;
|
|
|
|
657
|
- uploadImageProvider.notifyListeners();
|
|
|
|
658
|
- } else if (index == 9) {
|
|
|
|
659
|
- uploadImageProvider.logo.process = 0;
|
|
|
|
660
|
- uploadImageProvider.logo.qiniuUrl = null;
|
|
|
|
661
|
- uploadImageProvider.logo.file = null;
|
|
|
|
662
|
- uploadImageProvider.notifyListeners();
|
|
|
|
663
|
- } else if (index == 10) {
|
|
|
|
664
|
- uploadImageProvider.storeImage5.process = 0;
|
|
|
|
665
|
- uploadImageProvider.storeImage5.qiniuUrl = null;
|
|
|
|
666
|
- uploadImageProvider.storeImage5.file = null;
|
|
|
|
667
|
- uploadImageProvider.notifyListeners();
|
|
|
|
668
|
- } else if (index == 11) {
|
|
|
|
669
|
- uploadImageProvider.storeImage6.process = 0;
|
|
|
|
670
|
- uploadImageProvider.storeImage6.qiniuUrl = null;
|
|
|
|
671
|
- uploadImageProvider.storeImage6.file = null;
|
|
|
|
672
|
- uploadImageProvider.notifyListeners();
|
|
|
|
673
|
- }
|
|
|
|
674
|
- // 取消当前任务
|
|
|
|
675
|
- putController.cancel();
|
552
|
+ .then((PutResponse response) {
|
|
|
|
553
|
+ print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}');
|
|
|
|
554
|
+ print('------------------------');
|
|
|
|
555
|
+ String imgUrl = uploadImageProvider.qiniuInfoSunModel!.domain! +
|
|
|
|
556
|
+ '/' +
|
|
|
|
557
|
+ response.rawData['key'];
|
|
|
|
558
|
+
|
|
|
|
559
|
+ // 取消当前任务
|
|
|
|
560
|
+ // putController.cancel();
|
|
|
|
561
|
+ if (index == 0) {
|
|
|
|
562
|
+ uploadImageProvider.touxiang.process = 1;
|
|
|
|
563
|
+ uploadImageProvider.touxiang.qiniuUrl = imgUrl;
|
|
|
|
564
|
+ uploadImageProvider.touxiang.file = null;
|
|
|
|
565
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
566
|
+ callback!();
|
|
|
|
567
|
+ } else if (index == 1) {
|
|
|
|
568
|
+ uploadImageProvider.erweima.process = 1;
|
|
|
|
569
|
+ uploadImageProvider.erweima.qiniuUrl = imgUrl;
|
|
|
|
570
|
+ uploadImageProvider.erweima.file = null;
|
|
|
|
571
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
572
|
+ callback!();
|
|
|
|
573
|
+ } else if (index == 2) {
|
|
|
|
574
|
+ uploadImageProvider.mentou.process = 1;
|
|
|
|
575
|
+ uploadImageProvider.mentou.qiniuUrl = imgUrl;
|
|
|
|
576
|
+ uploadImageProvider.mentou.file = null;
|
|
|
|
577
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
578
|
+ callback!();
|
|
|
|
579
|
+ } else if (index == 3) {
|
|
|
|
580
|
+ uploadImageProvider.dish.process = 1;
|
|
|
|
581
|
+ uploadImageProvider.dish.qiniuUrl = imgUrl;
|
|
|
|
582
|
+ uploadImageProvider.dish.file = null;
|
|
|
|
583
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
584
|
+ callback!();
|
|
|
|
585
|
+ } else if (index == 4) {
|
|
|
|
586
|
+ uploadImageProvider.firstImage.process = 1;
|
|
|
|
587
|
+ uploadImageProvider.firstImage.qiniuUrl = imgUrl;
|
|
|
|
588
|
+ uploadImageProvider.firstImage.file = null;
|
|
|
|
589
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
590
|
+ callback!();
|
|
|
|
591
|
+ } else if (index == 5) {
|
|
|
|
592
|
+ uploadImageProvider.storeImage1.process = 1;
|
|
|
|
593
|
+ uploadImageProvider.storeImage1.qiniuUrl = imgUrl;
|
|
|
|
594
|
+ uploadImageProvider.storeImage1.file = null;
|
|
|
|
595
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
596
|
+ callback!();
|
|
|
|
597
|
+ } else if (index == 6) {
|
|
|
|
598
|
+ uploadImageProvider.storeImage2.process = 1;
|
|
|
|
599
|
+ uploadImageProvider.storeImage2.qiniuUrl = imgUrl;
|
|
|
|
600
|
+ uploadImageProvider.storeImage2.file = null;
|
|
|
|
601
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
602
|
+ callback!();
|
|
|
|
603
|
+ } else if (index == 7) {
|
|
|
|
604
|
+ uploadImageProvider.storeImage3.process = 1;
|
|
|
|
605
|
+ uploadImageProvider.storeImage3.qiniuUrl = imgUrl;
|
|
|
|
606
|
+ uploadImageProvider.storeImage3.file = null;
|
|
676
|
uploadImageProvider.notifyListeners();
|
607
|
uploadImageProvider.notifyListeners();
|
|
677
|
- if (error is StorageError) {
|
|
|
|
678
|
- switch (error.type) {
|
|
|
|
679
|
- case StorageErrorType.CONNECT_TIMEOUT:
|
|
|
|
680
|
- Utils.showToast('发生错误: 连接超时');
|
|
|
|
681
|
- break;
|
|
|
|
682
|
- case StorageErrorType.SEND_TIMEOUT:
|
|
|
|
683
|
- print('发生错误: 发送数据超时');
|
|
|
|
684
|
- Utils.showToast('发生错误: 发送数据超时');
|
|
|
|
685
|
- break;
|
|
|
|
686
|
- case StorageErrorType.RECEIVE_TIMEOUT:
|
|
|
|
687
|
- print('发生错误: 响应数据超时');
|
|
|
|
688
|
- Utils.showToast('发生错误: 响应数据超时');
|
|
|
|
689
|
- break;
|
|
|
|
690
|
- case StorageErrorType.RESPONSE:
|
|
|
|
691
|
- print('发生错误: ${error.message}');
|
|
|
|
692
|
- // Utils.showToast('发生错误000: ${error}');
|
|
|
|
693
|
- // Utils.showToast('发生错误000: ${error.code}');
|
|
|
|
694
|
- Utils.showToast('发生错误: ${error.message}');
|
|
|
|
695
|
- break;
|
|
|
|
696
|
- case StorageErrorType.CANCEL:
|
|
|
|
697
|
- print('发生错误: 请求取消');
|
|
|
|
698
|
- Utils.showToast('发生错误: 请求取消');
|
|
|
|
699
|
- break;
|
|
|
|
700
|
- case StorageErrorType.UNKNOWN:
|
|
|
|
701
|
- print('发生错误: ');
|
|
|
|
702
|
- Utils.showToast('发生错误: 未知错误');
|
|
|
|
703
|
- break;
|
|
|
|
704
|
- case StorageErrorType.NO_AVAILABLE_HOST:
|
|
|
|
705
|
- print('发生错误: 无可用 Host');
|
|
|
|
706
|
- Utils.showToast('发生错误: 无可用 Host');
|
|
|
|
707
|
- break;
|
|
|
|
708
|
- case StorageErrorType.IN_PROGRESS:
|
|
|
|
709
|
- print('发生错误: 已在队列中');
|
|
|
|
710
|
- Utils.showToast('发生错误: 已在队列中');
|
|
|
|
711
|
- break;
|
|
|
|
712
|
- // case StorageErrorType.NO_AVAILABLE_REGION:
|
|
|
|
713
|
- // TODO: Handle this case.
|
|
|
|
714
|
- }
|
|
|
|
715
|
- } else {
|
|
|
|
716
|
- print('发生错误: ${error.toString()}');
|
|
|
|
717
|
- Utils.showToast('发生错误: ${error.toString()}');
|
608
|
+ callback!();
|
|
|
|
609
|
+ } else if (index == 8) {
|
|
|
|
610
|
+ uploadImageProvider.storeImage4.process = 1;
|
|
|
|
611
|
+ uploadImageProvider.storeImage4.qiniuUrl = imgUrl;
|
|
|
|
612
|
+ uploadImageProvider.storeImage4.file = null;
|
|
|
|
613
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
614
|
+ callback!();
|
|
|
|
615
|
+ } else if (index == 9) {
|
|
|
|
616
|
+ uploadImageProvider.logo.process = 1;
|
|
|
|
617
|
+ uploadImageProvider.logo.qiniuUrl = imgUrl;
|
|
|
|
618
|
+ uploadImageProvider.logo.file = null;
|
|
|
|
619
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
620
|
+ callback!();
|
|
|
|
621
|
+ } else if (index == 10) {
|
|
|
|
622
|
+ uploadImageProvider.storeImage5.process = 1;
|
|
|
|
623
|
+ uploadImageProvider.storeImage5.qiniuUrl = imgUrl;
|
|
|
|
624
|
+ uploadImageProvider.storeImage5.file = null;
|
|
|
|
625
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
626
|
+ callback!();
|
|
|
|
627
|
+ } else if (index == 11) {
|
|
|
|
628
|
+ uploadImageProvider.storeImage6.process = 1;
|
|
|
|
629
|
+ uploadImageProvider.storeImage6.qiniuUrl = imgUrl;
|
|
|
|
630
|
+ uploadImageProvider.storeImage6.file = null;
|
|
|
|
631
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
632
|
+ callback!();
|
|
|
|
633
|
+ }
|
|
|
|
634
|
+ }).catchError((dynamic error) {
|
|
|
|
635
|
+ if (index == 0) {
|
|
|
|
636
|
+ uploadImageProvider.touxiang.process = 0;
|
|
|
|
637
|
+ uploadImageProvider.touxiang.qiniuUrl = null;
|
|
|
|
638
|
+ uploadImageProvider.touxiang.file = null;
|
|
|
|
639
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
640
|
+ } else if (index == 1) {
|
|
|
|
641
|
+ uploadImageProvider.erweima.process = 0;
|
|
|
|
642
|
+ uploadImageProvider.erweima.qiniuUrl = null;
|
|
|
|
643
|
+ uploadImageProvider.erweima.file = null;
|
|
|
|
644
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
645
|
+ } else if (index == 2) {
|
|
|
|
646
|
+ uploadImageProvider.mentou.process = 0;
|
|
|
|
647
|
+ uploadImageProvider.mentou.qiniuUrl = null;
|
|
|
|
648
|
+ uploadImageProvider.mentou.file = null;
|
|
|
|
649
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
650
|
+ } else if (index == 3) {
|
|
|
|
651
|
+ uploadImageProvider.dish.process = 0;
|
|
|
|
652
|
+ uploadImageProvider.dish.qiniuUrl = null;
|
|
|
|
653
|
+ uploadImageProvider.dish.file = null;
|
|
|
|
654
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
655
|
+ } else if (index == 4) {
|
|
|
|
656
|
+ uploadImageProvider.firstImage.process = 0;
|
|
|
|
657
|
+ uploadImageProvider.firstImage.qiniuUrl = null;
|
|
|
|
658
|
+ uploadImageProvider.firstImage.file = null;
|
|
|
|
659
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
660
|
+ } else if (index == 5) {
|
|
|
|
661
|
+ uploadImageProvider.storeImage1.process = 0;
|
|
|
|
662
|
+ uploadImageProvider.storeImage1.qiniuUrl = null;
|
|
|
|
663
|
+ uploadImageProvider.storeImage1.file = null;
|
|
|
|
664
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
665
|
+ } else if (index == 6) {
|
|
|
|
666
|
+ uploadImageProvider.storeImage2.process = 0;
|
|
|
|
667
|
+ uploadImageProvider.storeImage2.qiniuUrl = null;
|
|
|
|
668
|
+ uploadImageProvider.storeImage2.file = null;
|
|
|
|
669
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
670
|
+ } else if (index == 7) {
|
|
|
|
671
|
+ uploadImageProvider.storeImage3.process = 0;
|
|
|
|
672
|
+ uploadImageProvider.storeImage3.qiniuUrl = null;
|
|
|
|
673
|
+ uploadImageProvider.storeImage3.file = null;
|
|
|
|
674
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
675
|
+ } else if (index == 8) {
|
|
|
|
676
|
+ uploadImageProvider.storeImage4.process = 0;
|
|
|
|
677
|
+ uploadImageProvider.storeImage4.qiniuUrl = null;
|
|
|
|
678
|
+ uploadImageProvider.storeImage4.file = null;
|
|
|
|
679
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
680
|
+ } else if (index == 9) {
|
|
|
|
681
|
+ uploadImageProvider.logo.process = 0;
|
|
|
|
682
|
+ uploadImageProvider.logo.qiniuUrl = null;
|
|
|
|
683
|
+ uploadImageProvider.logo.file = null;
|
|
|
|
684
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
685
|
+ } else if (index == 10) {
|
|
|
|
686
|
+ uploadImageProvider.storeImage5.process = 0;
|
|
|
|
687
|
+ uploadImageProvider.storeImage5.qiniuUrl = null;
|
|
|
|
688
|
+ uploadImageProvider.storeImage5.file = null;
|
|
|
|
689
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
690
|
+ } else if (index == 11) {
|
|
|
|
691
|
+ uploadImageProvider.storeImage6.process = 0;
|
|
|
|
692
|
+ uploadImageProvider.storeImage6.qiniuUrl = null;
|
|
|
|
693
|
+ uploadImageProvider.storeImage6.file = null;
|
|
|
|
694
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
695
|
+ }
|
|
|
|
696
|
+ // 取消当前任务
|
|
|
|
697
|
+ putController.cancel();
|
|
|
|
698
|
+ uploadImageProvider.notifyListeners();
|
|
|
|
699
|
+ if (error is StorageError) {
|
|
|
|
700
|
+ switch (error.type) {
|
|
|
|
701
|
+ case StorageErrorType.CONNECT_TIMEOUT:
|
|
|
|
702
|
+ Utils.showToast('发生错误: 连接超时');
|
|
|
|
703
|
+ break;
|
|
|
|
704
|
+ case StorageErrorType.SEND_TIMEOUT:
|
|
|
|
705
|
+ print('发生错误: 发送数据超时');
|
|
|
|
706
|
+ Utils.showToast('发生错误: 发送数据超时');
|
|
|
|
707
|
+ break;
|
|
|
|
708
|
+ case StorageErrorType.RECEIVE_TIMEOUT:
|
|
|
|
709
|
+ print('发生错误: 响应数据超时');
|
|
|
|
710
|
+ Utils.showToast('发生错误: 响应数据超时');
|
|
|
|
711
|
+ break;
|
|
|
|
712
|
+ case StorageErrorType.RESPONSE:
|
|
|
|
713
|
+ print('发生错误: ${error.message}');
|
|
|
|
714
|
+ // Utils.showToast('发生错误000: ${error}');
|
|
|
|
715
|
+ // Utils.showToast('发生错误000: ${error.code}');
|
|
|
|
716
|
+ Utils.showToast('发生错误: ${error.message}');
|
|
|
|
717
|
+ break;
|
|
|
|
718
|
+ case StorageErrorType.CANCEL:
|
|
|
|
719
|
+ print('发生错误: 请求取消');
|
|
|
|
720
|
+ Utils.showToast('发生错误: 请求取消');
|
|
|
|
721
|
+ break;
|
|
|
|
722
|
+ case StorageErrorType.UNKNOWN:
|
|
|
|
723
|
+ print('发生错误: ');
|
|
|
|
724
|
+ Utils.showToast('发生错误: 未知错误');
|
|
|
|
725
|
+ break;
|
|
|
|
726
|
+ case StorageErrorType.NO_AVAILABLE_HOST:
|
|
|
|
727
|
+ print('发生错误: 无可用 Host');
|
|
|
|
728
|
+ Utils.showToast('发生错误: 无可用 Host');
|
|
|
|
729
|
+ break;
|
|
|
|
730
|
+ case StorageErrorType.IN_PROGRESS:
|
|
|
|
731
|
+ print('发生错误: 已在队列中');
|
|
|
|
732
|
+ Utils.showToast('发生错误: 已在队列中');
|
|
|
|
733
|
+ break;
|
|
|
|
734
|
+ // case StorageErrorType.NO_AVAILABLE_REGION:
|
|
|
|
735
|
+ // TODO: Handle this case.
|
|
718
|
}
|
736
|
}
|
|
|
|
737
|
+ } else {
|
|
|
|
738
|
+ print('发生错误: ${error.toString()}');
|
|
|
|
739
|
+ Utils.showToast('发生错误: ${error.toString()}');
|
|
|
|
740
|
+ }
|
|
719
|
|
741
|
|
|
720
|
- print('------------------------');
|
|
|
|
721
|
- });
|
742
|
+ print('------------------------');
|
|
|
|
743
|
+ });
|
|
722
|
}
|
744
|
}
|
|
723
|
} |
745
|
} |