-
-
Notifications
You must be signed in to change notification settings - Fork 878
Custom File Upload Controller #1114
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
Conversation
Parse/PFFile.h
Outdated
@@ -152,6 +154,11 @@ NS_ASSUME_NONNULL_BEGIN | |||
///-------------------------------------- | |||
|
|||
/** | |||
Sets a custom upload controller that synchronously uploads the file using its own policy. | |||
*/ | |||
@property (nonatomic, strong, readwrite, nullable) id<PFFileUploadController> uploadController; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put the controller part of the configuration to avoid mismatches, keep it there as well to use the default uploader for a particular file no?
return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState]; | ||
}]; | ||
|
||
if (uploadController) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not have a default controller that proceeded the PFRESTFileCommand
this way the upload controller could be:
uploadController = uploadController ?: [PFRestFileUploadController default]
to application's parse server. Allows for direct uploads to other file storage | ||
providers. | ||
*/ | ||
@protocol PFFileUploadController <NSObject> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could very well have the PFRESTFileUploadController: NSObject<PFFileUploadController>
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely. I originally started to go that route, but wanted to minimize touching the code base. I'll make that change. I assume you want the PFRESTFileUploadController to have a public .h?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an internal one, not really a need to be exposed. The protocol needs to be however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will do. Few things to do first, but will get to it in a bit.
For your use case, you'd wanna use that upload controller for all files right? Would there be an easy way to add that probably to the parse initialization? or it would not work for your use case? |
Yes, that would be a better API. Could create a default at initialization, and have an override on PFFile? I don't really need the latter, but seems like someone might. |
KISS, if we can easily access/init at init time, let's not provide an override at PFFile time. We'll revisit if one really need to go the per-PFFile route. What do you think? |
Works for me. I'll do that as part of the change. |
Awesome! There's no rush here but 🙇 for that PR :) |
BTW, while I don't have the time to go through the learning curve of adding a cocoapod/package.json to PFFileS3UploaderController and the associated cloud code, they would be generally useful. Any interest in doing that packaging if I put up public repos for them? |
Yeh, I could have a look :) |
For your S3 uploaded, we can put them on parse-server-modules org. If you don't mind :) |
…configuration. Created a default PFFileUploadController policy for parse-server REST upload rather than hard coding it in PFFileController.
…eUploadController; it exposed too many internals.
Sounds good. I'll put up public repos in the next couple of days. Encapsulating the default REST upload implementation as an implementor of PFFileUploadController sounded good, but it caused a lot of internals to be exposed (most notably, it required the instance of PFFileController for its commandRunner). I've backed out my earlier erroneous commit. Also, I think I may have found an existing bug in PFFileController, but didn't want to make the change without making sure it doesn't have side effects. The mime type doesn't get passed along to the PFFileState. It might explain #997, which has actually been a nuisance for me for years now.
|
I've created a simple container repo that has the server and iOS code in it. https://github.com/kcoop/Parse-S3FileUploaderSTS Sorry, no instructions for STS config in the readme. Sadly didn't take notes as I implemented it, and there's a bit involved. |
Sorry for the chatty commits. Haven't been able to run test suites. rake test:ios doesn't seem to work.
I'm also having difficulty figuring out how the latest test failure could be related to my commits:
|
Am I missing something obvious with not being able to run the test suite? Shouldn't it just be rake test:ios? |
@flovilmart, I'd like to get this buttoned down so I can move on to other things (I'd rather commit a Podfile.lock that refers to your repo than mine). I'm more than happy to debug this failure, but I don't have a good workflow for doing so. I don't see any docs for how I can run the tests, let alone how to attach the debugger as they run. BTW, I'm really enjoying seeing files upload to S3 without touching my server. Well, maybe not today, thanks Amazon. :-P |
For the tests, I believe the command is Otherwise I can have a look later this week |
That's basically what I've been doing, still fails as mentioned above. The Rakefile that's in head doesn't refer to the same set of destination specifiers, it only refers to iPhone 4 and iPhone 6. Seems like something in the travis build sets these up? Any thoughts on how to attach a debugger to this? And again, the test that's failing checks whether the Parse directory is present in the file system, and I guess it is? Strange that the changes in this pull request would do that. Anyway, no worries, I understand busy. Just let me know. |
I'll get the PR branch and have a look.otherwise run tests in Xcode should work no? |
Doesn't build. |
uhm.. yeah it's not updated for xcode8, there is a PR for that, but... |
Huh. Now it passes. |
Seems that travis is still drunk from all the S3 issue and they incurred a huge build backlog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, otherwise that looks awesome
Parse/PFFileUploadController.h
Outdated
|
||
#import <Foundation/Foundation.h> | ||
#import <Bolts/BFTask.h> | ||
#import "PFFileUploadResult.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add that protocol in the global import header, CI is complaining about non modular header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should just use forward declaration through @class PFFileUploadResult
instead of header import here.
Parse/ParseClientConfiguration.h
Outdated
@@ -10,6 +10,7 @@ | |||
#import <Foundation/Foundation.h> | |||
|
|||
#import <Parse/PFConstants.h> | |||
#import "PFFileUploadController.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import should probably be #import <Parse/PFFileUploadController.h>
or even better, a forward @class PFFileUploadController
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done, it builds, but I have to commit to test it. Here goes...
I've also added #import <Parse/PFFileUploadController.h>
to the global import header.
Out of curiosity, why prefer the forward @protocol over the import? Don't see any cycles here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because the header is 'exported' that avoids the confusion between import <module/header.h> vs import "header.h"
🙇 sorry for the back and forth 🙇 |
… header file. Changed ref to PFFileUploadController.h to a forward declaration.
@kcoop let's merge that, I'll release the next version soon. |
…1.14.4 * commit 'b5c49540caf930dbaf47a9c0f07cddac6cdd9674': Parse 1.14.4 (parse-community#1131) Custom File Upload Controller (parse-community#1114) transfer code Bundle check (parse-community#1119) # Conflicts: # Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m
@kcoop I like the idea, let's bring it in!