mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:39:37 -05:00 
			
		
		
		
	refactor: mobile - send livephoto as a separate request (#5275)
* refactor: mobile - send livephoto as a separate request * fix: create new request for live asset --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									ad06502539
								
							
						
					
					
						commit
						e65d1d5930
					
				@ -278,13 +278,6 @@ class BackupService {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          req.files.add(assetRawUploadData);
 | 
					          req.files.add(assetRawUploadData);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (entity.isLivePhoto) {
 | 
					 | 
				
			||||||
            var livePhotoRawUploadData = await _getLivePhotoFile(entity);
 | 
					 | 
				
			||||||
            if (livePhotoRawUploadData != null) {
 | 
					 | 
				
			||||||
              req.files.add(livePhotoRawUploadData);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          setCurrentUploadAssetCb(
 | 
					          setCurrentUploadAssetCb(
 | 
				
			||||||
            CurrentUploadAsset(
 | 
					            CurrentUploadAsset(
 | 
				
			||||||
              id: entity.id,
 | 
					              id: entity.id,
 | 
				
			||||||
@ -299,6 +292,29 @@ class BackupService {
 | 
				
			|||||||
          var response =
 | 
					          var response =
 | 
				
			||||||
              await httpClient.send(req, cancellationToken: cancelToken);
 | 
					              await httpClient.send(req, cancellationToken: cancelToken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          // Send live photo separately
 | 
				
			||||||
 | 
					          if (entity.isLivePhoto) {
 | 
				
			||||||
 | 
					            var livePhotoRawUploadData = await _getLivePhotoFile(entity);
 | 
				
			||||||
 | 
					            if (livePhotoRawUploadData != null) {
 | 
				
			||||||
 | 
					              var livePhotoReq = MultipartRequest(
 | 
				
			||||||
 | 
					                req.method,
 | 
				
			||||||
 | 
					                req.url,
 | 
				
			||||||
 | 
					                onProgress: req.onProgress,
 | 
				
			||||||
 | 
					              )
 | 
				
			||||||
 | 
					                ..headers.addAll(req.headers)
 | 
				
			||||||
 | 
					                ..fields.addAll(req.fields);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              livePhotoReq.files.add(livePhotoRawUploadData);
 | 
				
			||||||
 | 
					              // Send live photo only if the non-motion part is successful
 | 
				
			||||||
 | 
					              if (response.statusCode == 200 || response.statusCode == 201) {
 | 
				
			||||||
 | 
					                response = await httpClient.send(
 | 
				
			||||||
 | 
					                  livePhotoReq,
 | 
				
			||||||
 | 
					                  cancellationToken: cancelToken,
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (response.statusCode == 200) {
 | 
					          if (response.statusCode == 200) {
 | 
				
			||||||
            // asset is a duplicate (already exists on the server)
 | 
					            // asset is a duplicate (already exists on the server)
 | 
				
			||||||
            duplicatedAssetIds.add(entity.id);
 | 
					            duplicatedAssetIds.add(entity.id);
 | 
				
			||||||
@ -356,7 +372,7 @@ class BackupService {
 | 
				
			|||||||
      var fileStream = motionFile.openRead();
 | 
					      var fileStream = motionFile.openRead();
 | 
				
			||||||
      String fileName = p.basename(motionFile.path);
 | 
					      String fileName = p.basename(motionFile.path);
 | 
				
			||||||
      return http.MultipartFile(
 | 
					      return http.MultipartFile(
 | 
				
			||||||
        "livePhotoData",
 | 
					        "assetData",
 | 
				
			||||||
        fileStream,
 | 
					        fileStream,
 | 
				
			||||||
        motionFile.lengthSync(),
 | 
					        motionFile.lengthSync(),
 | 
				
			||||||
        filename: fileName,
 | 
					        filename: fileName,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user