tusdotnet icon indicating copy to clipboard operation
tusdotnet copied to clipboard

The operation couldn’t be completed. (TUSKit.TUSClientError error 7.)

Open Shivam-becker opened this issue 2 years ago • 1 comments

The operation couldn’t be completed. (TUSKit.TUSClientError error 7.)

It's working fine with android but not iOS. I am using TUSKit pod Version 3.1.2 Xcode Version 13.0 using Swift 5. This is how I'm initializing. Calling this method in viewDidLoad : - func initialiseTUSClient() { do { tusClient = try TUSClient(server: URL(string: "https://0b37-122-160-69-90.in.ngrok.io/uploads")!, sessionIdentifier: "Axle") tusClient?.delegate = self tusClient?.start() } catch { Debugger.sharedInstance.printToConsole(message: "Error: Could not intialise TUS Client") } }

This is what I'm calling on button action :-

let imageAsset = self.selectedImagesAssetsArray.first?.asset //PHAsset PHImageManager.default().requestImage(for: imageAsset!, targetSize: self.assetThumbnailSize, contentMode: .aspectFill, options: nil, resultHandler: {(result, info)in if result != nil { do { let imageDataJpeg = result!.jpegData(compressionQuality: 0.7) let imgDataBase64 = imageDataJpeg!.base64EncodedData() try self.tusClient?.upload(data: imgDataBase64, customHeaders: ["filetype":".jpeg"]) } catch { Debugger.sharedInstance.printToConsole(message: "Unable to upload.Inside Catch Block") }

        }
    })

Here is server configuration , We are using Dotnet core 6.0 as backend (tusdotnet client 2.6.0)

app.Use((context, next) => { context.Features.Get().MaxRequestBodySize = null; return next.Invoke(); });

app.UseTus(httpContext => new DefaultTusConfiguration { Store = new TusDiskStore("wwwroot/uploads/chunkData"), UrlPath = "/uploads", MetadataParsingStrategy = MetadataParsingStrategy.AllowEmptyValues, Expiration = new AbsoluteExpiration(TimeSpan.FromMinutes(5)),

Events = new Events { OnFileCompleteAsync = async eventContext => {

    ITusFile file = await eventContext.GetFileAsync();
    if (file != null)
    {


        //Get upload file=
        var metadata = await file.GetMetadataAsync(eventContext.CancellationToken);

        //Get the target file name in the above file metadata
        var fileNameMetadata = metadata.ContainsKey("filename") ? metadata["filename"] : metadata["name"];

        //The target file name is encoded in Base64, so it needs to be decoded here
        var fileName = fileNameMetadata.GetString(Encoding.UTF8);

        var extensionName = Path.GetExtension(fileName);
        //Convert the uploaded file to the actual target file
        File.Move(Path.Combine("wwwroot/uploads/chunkData", eventContext.FileId), Path.Combine("wwwroot/uploads/", $"{eventContext.FileId},{extensionName}"));
        File.Delete(Path.Combine("wwwroot/uploads/chunkData", $"{eventContext.FileId}.chunkstart"));
        File.Delete(Path.Combine("wwwroot/uploads/chunkData", $"{eventContext.FileId}.chunkcomplete"));
        File.Delete(Path.Combine("wwwroot/uploads/chunkData", $"{eventContext.FileId}.uploadlength"));
        File.Delete(Path.Combine("wwwroot/uploads/chunkData", $"{eventContext.FileId}.metadata"));
    }
}

} });

Shivam-becker avatar Aug 03 '22 06:08 Shivam-becker

If it works with one client but not another I would say that the issue is with the client. I can't see anything wrong in your server setup so you will probably have a better chance of getting an answer if asking in the TUSKit repo: https://github.com/tus/TUSKit

I know from earlier experience that ngrok can be a culprit in these kind of things but can't say for sure as my knowledge of Swift (or is that Objective-C?) are very limited.

smatsson avatar Aug 09 '22 09:08 smatsson

No update for more than 30 days

smatsson avatar Oct 04 '22 17:10 smatsson