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

MOVE on chunked upload #31973

Closed
parzival418 opened this issue Jul 4, 2018 · 8 comments
Closed

MOVE on chunked upload #31973

parzival418 opened this issue Jul 4, 2018 · 8 comments

Comments

@parzival418
Copy link

I posted an issue yesterday trying to solve an issue I was having with chunked upload. I hit another seeming wall with the process. As there is not much documentation for this process, i thought I would ask again, and perhaps @DeepDiver1975 might be able to help.

Currently, I am now uplloading each chunk to the endpoint /owncloud/remote.php/dav/uploads/admin/:uploadid/:chunknumber. I increment the chunk number for each new chunk. I wind up with a file with a bunch of numbered files in it.

Once all chunks are completed, I then call a MOVE command on /owncloud/remote.php/dav/uploads/admin/:uploadid with the location to move the file to. The file moved successfully, but it is just the same folder with all the numbered files in it. The chunks were not assembled on the move.

What am I doing wrong? I have scoured the internet to find info on this without much luck,

Thanks in advance!

@ownclouders
Copy link
Contributor

GitMate.io thinks the contributor most likely able to help you is @PVince81.

Possibly related issues are #11106 (Parallel upload of chunks), #15647 (Work directly on storage in chunk upload mode), #16278 (Problems with Chunked upload), #8955 (Web Based File Upload Chunking), and #17066 (Upload movie fail : chunking loop).

@phil-davis
Copy link
Contributor

It depends if you are doing the "old" or "new" chunking. Sounds like "new" chunking. Have a look in:
https://github.com/owncloud/core/blob/master/tests/acceptance/features/bootstrap/WebDav.php
The clues are in:
userUploadsChunksUsingNewChunking()
which does:
userCreatesANewChunkingUploadWithId()
then upload each of the chunks:
userUploadsNewChunkFileOfWithToId()
then do the move to put the file together in place:
userMovesNewChunkFileWithIdToMychunkedfile()

https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdav/webdav-related-new-endpoint.feature
has test scenarios that call the above stuff, and do small multi-chuck uploads.

@DeepDiver1975
Copy link
Member

see here:

request($client, 'MOVE', "$uploadUrl/.file", null, [

@parzival418
Copy link
Author

parzival418 commented Jul 4, 2018

Thanks for the response!

I am using the new chunking method. I have looked over the linked resource, and I think I see what is going on (I am not a PHP dev, so some of the syntax is a little new for me).

I still can't quite locate where my code is going wrong however... I will share the two major places that are executing the calls:

// Config object:
 const config = {
    headers: {
      'Access-Control-Allow-Origin': 'https://localhost:8080', 
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    auth: fileObj.ocCredentials,
    onUploadProgress: progressEvent => {
      fileObj.setMultipartProgress(
        progressEvent,
        totalParts,
        currentPart
      );
  }

// uploadUrl is 
//  `http://myowncloudinstance/owncloud/remote.php/dav/uploads/${username}/${uploadId}`
// Folder was first created on the backend with a MKCOL to the above endpoint, url was returned to client.

this.http
  .put(part.uploadUrl, part.data, part.config)
  .then(response => {
    this.$emit("chunkUploaded", part.fileObj, part.currentPart);
    this.processQueue(queue, fileObj, response);
  })

Second part that deals with the move itself looks like this:

return this.http({
  url: fileObj.chunkedUploadUrl,
  method: 'MOVE',
  auth: fileObj.ocCredentials,
  headers: {
    'Access-Control-Allow-Origin': 'https://localhost:8080',
    'Destination': fileObj.path
  }
})
  // destination is:
  // http://myowncloudinstance/owncloud/remote.php/dav/files/admin/SMB/tpsxrepos/file/path

.then(moveResponse => {
  this.$emit("fileUploaded", {
    file: fileObj,
    response: response.data
  });

  this.setUploading(false);
  return true;
})

All of these steps work now without errors. However, when the uploads file/folder is moved, it doesn't assemble the pieces. It looks to me like I am doing all the steps, but maybe I am missing . crucial header to the process or using a wrong destination path?

Thanks again for the help. I would be happy to contribute back after this with some documentation for these endpoints based on what I have learned as an independent developer of a customer client.

@phil-davis
Copy link
Contributor

In WebDav.php moveNewDavChunkToFinalFile it sets up:

$source = '/uploads/' . $user . '/' . $id . '/.file';

That finds its way through to the URL for the MOVE.
I think you need a "magic" /.file on the end of /uploads/username/uploadid - and that will trigger the endpoint code that re-assembles the file.

@parzival418
Copy link
Author

omg! It worked! Thank you again so much.

I will put together some documentation for getting chunked upload working with the API for anyone else like me that might have to interact with it. The /.file part wasn't documented anywhere, so thank you for pointing that out to me.

You guys rock.

@phil-davis
Copy link
Contributor

Hmmm - acceptance tests are the new "documentation" ;)

@lock
Copy link

lock bot commented Jul 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants