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

Upload file using SDK instead of XHR #2239

Merged
merged 1 commit into from
Nov 19, 2019
Merged

Upload file using SDK instead of XHR #2239

merged 1 commit into from
Nov 19, 2019

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented Oct 14, 2019

Description

Use owncloud-sdk for uploading files

Related Issue

None raised

Motivation and Context

As we'll add chunk upload later to the SDK, it makes sense to use the SDK for upload instead.
It will only be a matter of adding "maxChunkSize" to the options to have it using chunks.
I don't think we should implement chunking directly in Phoenix.

Also: as we use the SDK in other places we should be consistent and use it everywhere!

How Has This Been Tested?

Quick manual test with a file upload:

  • TEST: upload works in root 🤖
  • TEST: upload works in subdir 🤖
  • TEST: upload works in public page root 🤖
  • TEST: upload works in public page subdir 🤖
  • TEST: upload works in files drop 🤖
  • TEST: progress bar works
  • TEST: overwrite works in all above cases
  • TEST: upload with drag and drop in all the above cases
  • TEST: IE11...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

@PVince81 PVince81 added this to the backlog milestone Oct 14, 2019
@PVince81 PVince81 self-assigned this Oct 14, 2019
@PVince81
Copy link
Contributor Author

PVince81 commented Oct 14, 2019

@LukasHirt @DeepDiver1975 please have a look at this POC and also the linked dependencies in owncloud-sdk and let me know if this is ok before I continue applying the changes to the public upload.

I intend to delete FileUpload.js (but not FileUpload.vue) and later on we can implement chunking inside of owncloud-sdk: owncloud/owncloud-sdk#18

@ownclouders
Copy link
Contributor

💥 Acceptance tests XGAPortrait failed. Please find the screenshots inside ...

https://drone.owncloud.com/owncloud/phoenix/5702/

20191014-134143-754.png
20191014-134207-771.png
20191014-134231-191.png
20191014-134255-102.png
20191014-134318-468.png
20191014-134342-392.png

@ownclouders
Copy link
Contributor

💥 Acceptance tests iPhone failed. Please find the screenshots inside ...

https://drone.owncloud.com/owncloud/phoenix/5702/

20191014-134245-910.png
20191014-134306-808.png
20191014-134327-620.png
20191014-134348-266.png
20191014-134408-955.png
20191014-134429-422.png

@@ -1,6 +1,5 @@
import filesize from 'filesize'
import moment from 'moment'
import FileUpload from './FileUpload.js'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we delete FileUpload.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, when I'm done. See TODO list in top post

@PVince81
Copy link
Contributor Author

also we need to talk about "loadend" now (see conflict), I'm still not convinced that we need it.
especially we can't add it in davclient.js as that library has no polyfills in place and adding those there seems like overkill

@PVince81
Copy link
Contributor Author

seems loadend also fires after an error: https://humanwhocodes.com/blog/2012/05/22/working-with-files-in-javascript-part-3/

@PVince81
Copy link
Contributor Author

PVince81 commented Oct 14, 2019

more trouble: uploading into subdirs doesn't work because all the upload code assumptions so far was about using the full URL as prefix. this means we need to change many places to use the current folder for its path. This changes the paradigms a bit...

  • change URL use for upload to using path instead

@PVince81
Copy link
Contributor Author

I managed to fix the subdir upload but I'm now blocked as I can't test public upload: need #1951 first

@PVince81
Copy link
Contributor Author

note: acceptance tests to be added as part of ticket #2222

@LukasHirt
Copy link
Collaborator

seems loadend also fires after an error: https://humanwhocodes.com/blog/2012/05/22/working-with-files-in-javascript-part-3/

Exactly, that's what I mentioned here #2225 (comment) and why I used it at all.

@LukasHirt
Copy link
Collaborator

Anyway, like a lot the approach to move it into the sdk 👍

@PVince81 PVince81 force-pushed the upload-with-sdk branch 2 times, most recently from 878ef46 to 38e8c7e Compare November 7, 2019 18:35
@PVince81
Copy link
Contributor Author

PVince81 commented Nov 7, 2019

I've fixed the public link upload. I find some messy stuff there like the token sometimes being embedded in the path... I'll raise a separate ticket to address this debt as I'd prefer to have more transparency there where the file list components don't need to care about public or not. This might affect how SDK API is designed.

  • wait for SDK update + package.json + locks update
  • raise ticket for public link code mess (+ bugs with createFolder not accepting password...)

@PVince81
Copy link
Contributor Author

PVince81 commented Nov 12, 2019

  • rebase once the public upload acceptance tests are in place, as they will confirm that this works correctly
  • solve conflicts

@PVince81
Copy link
Contributor Author

all done. I did a quick run of some upload tests locally and they passed.

let's see if the whole suites run...

@ownclouders
Copy link
Contributor

💥 Acceptance tests SharingInternalUsers failed. Please find the screenshots inside ...

https://drone.owncloud.com/owncloud/phoenix/6469/

20191114-164643-214.png
20191114-164716-050.png

@PVince81
Copy link
Contributor Author

PVince81 commented Nov 15, 2019

  • BUG: upload issues on public link page: tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature:206 and others

@PVince81
Copy link
Contributor Author

Fixed files drop case. Glad to see that this could be caught by acceptance tests!

@PVince81
Copy link
Contributor Author

@LukasHirt all green in CI, just some bug that prevented it to appear published on Github.

Can we merge ?

@PVince81
Copy link
Contributor Author

PVince81 commented Nov 18, 2019

  • BUG: drag and drop from file manager onto the drop zone (overlay that appears when dragging) => it currently opens the file directly ?!

Use owncloud-sdk for uploading files for both the regular file view and
also public page.

Removed FileUpload.js as it is now obsolete.

Had to switch to using paths instead of URLs in the upload handlers.

There were some challenges because the public link page currently has
the token embedded into the absolute path.

Introduced dependency on join-path to avoid more path gymnastics in
various places.
@PVince81
Copy link
Contributor Author

Fixed drag and drop bug. It turns out that vue-dropzone needs a URL even though we don't use that functionality. I've fed it a dummy URL for now. To be cleant up in #1953

Copy link
Collaborator

@LukasHirt LukasHirt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@PVince81
Copy link
Contributor Author

One CI job got stuck on cloning. Restart build.

@PVince81 PVince81 merged commit 324d5a4 into master Nov 19, 2019
@delete-merged-branch delete-merged-branch bot deleted the upload-with-sdk branch November 19, 2019 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants