Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resume upload after restarting app #51

Closed
bishowu opened this issue Aug 8, 2019 · 7 comments
Closed

Can't resume upload after restarting app #51

bishowu opened this issue Aug 8, 2019 · 7 comments

Comments

@bishowu
Copy link

bishowu commented Aug 8, 2019

I can't find a way to resume the last upload after restarting app. Is there a way to resume uploading the same file to the same temporary file ? Thank you
(I found that the upload id is different from the last upload id and the file will be uploaded to a new temporary file.)

Here is my codes written by swift4

    let asset = PHAsset.fetchAssets(withLocalIdentifiers: [media.mediaId], options: PHFetchOptions()).firstObject!
    let resource = PHAssetResource.assetResources(for: asset).first!
    let resourceURL = resource.value(forKey: "fileURL") as! URL
    
    let serverUrl = URL(string: "http://192.168.1.111:1080/files/")
    let uploadStore = TUSFileUploadStore(url: resourceURL)
    let session = TUSSession(endpoint: serverUrl!, dataStore: uploadStore!, allowsCellularAccess: true)
    let upload = session.createUpload(fromFile: resourceURL, retry: 3, headers: nil, metadata: nil)
           
    upload?.setChunkSize(1024*10)
    upload?.progressBlock = {
        (bytesWritten, bytesTotal) in
        print("upload progress = \(bytesWritten)/\(bytesTotal)")
    }
    
    upload?.failureBlock = {
        error in
        completionHandler("fail")
    }
    
    upload?.resultBlock = {
        fileURL in
        completionHandler("\(fileURL)")
    }
    
    upload?.resume()
@Acconut
Copy link
Member

Acconut commented Aug 12, 2019

@MMasterson Would you mind looking into this? :)

@MMasterson
Copy link
Contributor

@Acconut @bishowu Sorry for the delay!

@bishowu there is a method to upload to an already created file, however I believe it starts from 0. Let me take a deeper look today

@bishowu
Copy link
Author

bishowu commented Aug 19, 2019

@Acconut @MMasterson Thank you !
@MMasterson Is there any news on this ?

@MMasterson
Copy link
Contributor

@bishowu there isn't a way to keep track of uploads after restarting the app, but I can add the functionality and have it work like the Android implementation

@bishowu
Copy link
Author

bishowu commented Aug 21, 2019

@MMasterson I think the functionality is very useful, thank you.

@git-josip
Copy link

Hi @MMasterson ,
is there any update on this one ? :)

@MMasterson
Copy link
Contributor

Addressed in swift-development check #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants