Comments (12)
0.7.0-beta.2
includes a simple data response serializer that parses Amazon S3 Errors.
I'd like to add serializers for custom ACL responses and custom serializers for common data types that parse AmazonS3Errors.
from amazons3requestmanager.
I'd like to work on this since I desperately need this functionality. Which branch should I use as a starting point? And one concern: An extension on the Request class as you did seems a plausible way to achieve that. However, If we do that, we will have to call the dedicated serialiser method on the completed request depending on the return type. Like request.responseS3ListData(β¦)
, request.responseS3MeataData(β¦)
etc. How about we create subclasses of Request
like ListRequest
and override either response
or a dedicated property like s3response
. Like this on the usage side we can ensure that the correct serializer is called. Let me know what you think.
from amazons3requestmanager.
@sbhklr I see what you are going for, however I think that we should still with the custom serializer methods. There may be instances where the user does want to get the raw response data, or serialize it in a different way. By overriding response()
, we take away that capability.
This is the method that Alamofire
recommends and supports. Subclassing Request
may lead to incompatibility issues in later versions of Alamofire
.
@cnoon: What are your thoughts on subclassing Request
vs. creating custom serializers? Do you see this causing other unintended consequences?
from amazons3requestmanager.
@AnthonyMDev I see your point but instead of overriding response()
we could still create subclasses and override a custom property like s3response
. This should be safe. The problem there is that it's probably hard to find a function signature for s3response
that suits all use cases. For example listBucket()
should return a list of filenames while getObject()
should return data. The advantage with the current approach is that adding serializers doesn't break API compatibility with version 1.0.
from amazons3requestmanager.
@sbhklr I do see why that makes things more elegant.
Here's another thing to consider, when using the AmazonS3RequestSerializer
to create NSURLRequest
s but not using the AmazonS3RequestManager
, you can send these requests to a regular Alamofire.Manager
(or any other networking library for that matter). Using the default Alamofire.Manager
Β won't return our Request
subclass, but I'd still like users to be able to serialize the response using our custom serializers.
What if we created custom serializers, and also created custom Request
subclasses. On our subclasses, we can create a new func for s3Response
that uses the custom serializers. The AmazonS3RequestManager
can return our new subclasses, while still allowing regular old Request
objects to also use the custom serializers.
With this approach we maintain the flexibility of custom serializers while giving the elegant API that you are seeking as well.
from amazons3requestmanager.
Sounds reasonable. I'll give that a try tomorrow.
from amazons3requestmanager.
@sbhklr Thanks for taking this on!
from amazons3requestmanager.
Hey @AnthonyMDev, definitely don't subclass. You can't anyways b/c the init methods on a Request
are internal. You wouldn't be able to make a subclass instance with Alamofire even if you wanted to unless you made some much bigger changes to Alamofire itself. Instead, use the extension approach and add a custom serializer.
In order to mitigate the need for multiple serializers, you could always pass an enum case into your single S3 response serializer that specified what the expected response was. This would allow you to use a single response serializer for all the different types of responses. It would be very similar to the concept of validating a response status code.
Hopefully that helps.
from amazons3requestmanager.
@cnoon Thanks for your comments. I didn't even consider the initialization of the Request
.
@sbhklr Looks like we have to go with custom serializers.
from amazons3requestmanager.
@cnoon @AnthonyMDev I don't quite see why this shouldn't work. Subclassing Request
works for me. At least it compiles so far. And the instances of these subclasses don't have to be created by Alamofire but only by AmazonS3RequestManager
. They would use the according serializer that still can be implemented as an extension of Request
. The whole purpose is to provide the user of AmazonS3RequestManager
with an API that ensures the usage of the correct serializer.
from amazons3requestmanager.
@sbhklr I'll check out whatever you come up with. Either way, I definitely think that we need the custom serializers. We know we can use those either way.
If you can get the Request
subclasses to work, I'll check it out. I'm not sure how you are initializing the subclasses though without access to the initializers. I'm still concerned about the unintended consequences of subclassing Request
. Especially after:
definitely don't subclass. -@cnoon
You might want to do the custom serializers in one PR and the subclasses in a second PR, that way we have the ability to merge the serializers themselves if the subclasses don't work out.
from amazons3requestmanager.
I think we can close this issue. The serializers work.
from amazons3requestmanager.
Related Issues (20)
- errorWithCode(_:failureReason:) is deprecated in Alamofire
- Add operation to find bucket location
- Xcode 8 GM - Swift 2.3 fails to compile HOT 3
- please lower spec dependency to ios 8 HOT 9
- Remove CommonCrypto
- Add support for Pre-Signed URLs
- Break out Alamofire dependency into subspec
- Update `download` example in Readme HOT 4
- Issue for Alamofire 4.0.1 HOT 9
- S3BucketObjectList when using a delimiter doesn't extract the files correctly. HOT 2
- how to track the progress of uploading image or data or file to AS3RM HOT 1
- Example how get image from AWS and convert to UIImage? HOT 1
- Swift 2.3 release HOT 7
- Do amazonS3Manager.upload() function replace '+' character to white space character? HOT 2
- Chunk Upload & Download
- Add support multipart upload HOT 5
- Swift 4 support. HOT 2
- Xcode 9.0 beta compile error HOT 3
- Does not show any error on passing the wrong credentials HOT 1
- Can't compile several code snippets from Readme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazons3requestmanager.