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

chore: add upload of a blob file #86

Merged
merged 8 commits into from
Nov 9, 2018
Merged

Conversation

nicolastakashi
Copy link
Contributor

resolve issue #80

Copy link
Contributor

@erunion erunion left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for this! Just a few comments that I think will help to cut back on some duplicated functionality here so we can have a consistent upload flow through the upload method.

lib/vimeo.js Outdated
params = {}
}

var fileSize = file.size
Copy link
Contributor

Choose a reason for hiding this comment

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

To eliminate a lot of boilerplate and duplicated functionality, we could probably merge this line with line 436 and if file is a file object/blob, run this, else pass it through fs.statSync.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also if you don't mind, could you also mimic the same behavior within .replace so it can accept either a file path or a blob?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@erunion for sure sr, I will make this change. :)

Copy link

@vycoder vycoder Nov 8, 2018

Choose a reason for hiding this comment

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

Also if you don't mind, could you also mimic the same behavior within .replace so it can accept either a file path or a blob?

@nicolastakashi I just noticed that you forgot to include this one on your most recent revision.

Also, to anyone, is there any way I could change my local copy to work while waiting for the PR to get merged?

lib/vimeo.js Outdated
progressCallback,
errorCallback
) {
var upload = new tus.Upload(file, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the other comment, we can eliminate this method and merge it with _performTusUpload by detecting if file is a blob or string, and running it through fs.createReadStream depending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great! It's make sence, I will make the change

@vycoder
Copy link

vycoder commented Nov 8, 2018

Hi, any news on this? Will this enable me to upload videos from my client SPA using client.upload(file, completedCallback, progressCallback, errorCallback)??

@carlesjove
Copy link

@josephharveyangeles Yes, but notice that with the new method uploadFile.

client.uploadFile(file, completedCallback, progressCallback, errorCallback)

@nicolastakashi
Copy link
Contributor Author

Hi guys, sorry for my delay.

I had some difficulties and I coun't fixe the code that @erunion told me to fixe.

I'll to try fixe that until tomorrow and I let you know about that.

@carlesjove
Copy link

@nicolastakashi Thank you for your work on this. I just tried and works wonderfully. I'd like to help but I'm not that good at JS, but learning from your code! Meanwhile I'll create my own fork and merge your PR there. Again, thanks!

@nicolastakashi
Copy link
Contributor Author

Hey mate!

I just finish to fixe the code review.

Now I'll to make some tests and let you know about that.

tks

@vycoder
Copy link

vycoder commented Nov 8, 2018

I tested this just now, and it worked like a charm. When this PR got merged to master, on what version should would these changes reflect? I'm assuming the CI will automatically publish it on npm right? 2.1.0 or just like do yarn update or something. Sorry, quite new to the open-source scene.

@carlesjove
Copy link

@josephharveyangeles

Also, to anyone, is there any way I could change my local copy to work while waiting for the PR to get merged?

The safest approach would be to use a fork. You can create your own or use Nicola's. If you create your own, you'll have to merge Nicola's change yourself, either to master or another branch that you create. See this for reference: https://stackoverflow.com/a/6022366/1876328

Then, in your package manager simply use the git remote, instead of the library version:

"vimeo": "https://github.com/GITHUB_ACCOUNT/vimeo.js#YOUR_BRANCH"

@nicolastakashi
Copy link
Contributor Author

Hey you mates.

I just push a new version and I change the replace to acceppt file path or file.

I made some tests but I will appreciate if someone could make more tests to ensure the functionality

Copy link
Contributor

@erunion erunion left a comment

Choose a reason for hiding this comment

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

Just a few really minor things to avoid attempting to access properties on non-objects, but otherwise this is great!

lib/vimeo.js Show resolved Hide resolved
lib/vimeo.js Outdated Show resolved Hide resolved
lib/vimeo.js Outdated Show resolved Hide resolved
lib/vimeo.js Show resolved Hide resolved
lib/vimeo.js Outdated Show resolved Hide resolved
erunion and others added 5 commits November 9, 2018 14:08
Co-Authored-By: nicolastakashi <nicolas.tcs@hotmail.com>
Co-Authored-By: nicolastakashi <nicolas.tcs@hotmail.com>
Co-Authored-By: nicolastakashi <nicolas.tcs@hotmail.com>
Co-Authored-By: nicolastakashi <nicolas.tcs@hotmail.com>
Co-Authored-By: nicolastakashi <nicolas.tcs@hotmail.com>
@erunion erunion merged commit 1927074 into vimeo:master Nov 9, 2018
@nicolastakashi
Copy link
Contributor Author

Great Sr!

Was a pleasure to talk with you :)

If exists some other change that I could to do, please let me know <3

@erunion
Copy link
Contributor

erunion commented Nov 9, 2018

Fantastic. I just released this to 2.1.1.

Thanks @nicolastakashi, and everyone!

@erunion
Copy link
Contributor

erunion commented Dec 11, 2018

@jeffreylanters I believe you're referring to the try-catch-else bug? I fixed that in the release I did back in November for this feature.

@jeffreylanters
Copy link

jeffreylanters commented Dec 12, 2018

@erunion I see, we we're using @nicolastakashi's Fork. He should pull your fix into his repository then. Thanks for the response!

Edit: I just see his Fork is already merged into the master. We'll be fine using the master. Thanks again!

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

Successfully merging this pull request may close these issues.

None yet

5 participants