Uploading to Amazon-S3 via AFNetworking - ios

I'm having difficulty uploading files to S3 via AFNetworking. When I attempt to upload, I get callbacks indicating a small percentage of the file is uploaded, then the callbacks cease, and one or two minutes later I get a timeout message.
I'm using AFAmazonS3Client but it seems like a pretty straight forward subclass of AFHTTPClient so it seems unlikely the problem lies there. Since I'm new to both AFNetworking and S3, I'm pretty sure the problem is typing this message :)
I've downloaded the AWS-IOS SDK and was able to post a picture from their sample code without a problem. So I don't think its a misconfiguration of my S3 account.

After struggling a bit with the same problem and a bit of research, I found a solution that seems to work well.
Download the Amazon AWS SDK for iOS and add it to your project:
http://aws.amazon.com/sdkforios/
Then, implement the upload test with a custom NSOperation class as explained here:
Using delegates, operations, and queues
The AmazonServiceRequestDelegate protocol is the key to get progress updates, in a similar fashion to what AFNetworking does.
In particular, this method is what I needed:
-(void)request:(AmazonServiceRequest *)request didSendData:(NSInteger)bytesWritten
totalBytesWritten:(NSInteger)totalBytesWritten
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;

Related

Check if resource at NSURL exists BEFORE downloading

I want to pull down new images from a website that is updated regularly. However, there is no API for that site, so I'm trying to fetch it by url, as the images are numbered. The way I've decided to do this is have the app query the website on first launch and loop through the URLs until I get a 404. Then I store that URL and on next launch loop through till I get another 404, etc. Now I know that is less than ideal, but I'm just building a prototype. Anyway…
Since these are images we're talking about, I can't just download them all on first launch. Waste of bandwidth, could take minutes or even hours… So I just need a way using NSURLSession or whatever to get the http status code for any given image without actually downloading it.
You can do this by getting the "HTTP Headers".
This answer will help, if you're comfortable porting Objective-C to help. I can help you with it if required.

Firebase : Upload image or file from dashboard

I'm trying to find a good alternative at Parse.
FireBase seems to be good, but I can't find how to upload image/file from the dashboard like in Parse ?
Can we upload image/file from the firebase dashboard like in Parse ?
No You Can Not because firebase doesn't provide such type of feature.
Edit:
Ah! My old accepted answer got unaccepted because I gave straight answer :) Well OP didn't ask about programming way of solution so I assumed not to provide one.
There are couple of approaches to handle images with firebase, I usually upload images to s3 bucket and store urls in firebase. Again there is choice to implement above approach i.e. do all on server-side, do all on client-side or do with mix of client-side and server-side. But It is better to do signaturing on server to keep thing secure.
Node-Cheat Available:
For complete code, get working node-cheat at github node-cheat aws, choose any folder and run node file_name.
While the above is an answer, it's does't provide a solution, so here's a bit more data.
Uploading/storing data in firebase is super simple and requires a minimal amount of code.
For images, encode the image as a string and store the string in firebase. Then to retrieve the image, retrieve the string and decode it.
You should be able to do both in about 12 lines of code (depending on platform).
There are several examples already published here, I like this one with Swift.
Swift2 retrieving images from Firebase
Hope that helps!
No, you cannot upload directly, but you could use some opensource project out there that will make a simple dashboard for you to upload it easily like this tutorial

Get data from server in iOS

I have a script that takes hours and outputs if it is open or closed and I want to run this on my server, and then from my iOS app get if a certain place is open or closed. And I was wondering how I could do this without generating an JSON file and then parsing that as I would to frequently re-generate the file as the things change from open to closed and such. So is there a way I could make a call to the server and just get the data that I want?
Im not entirely sure whether you are asking specifically for an iOS framework for requests and responses or server side. So I figure I will try to answer both. Here are some swift projects you might be interested in. I'm not incredibly familiar with objective c yet but these resources might prove useful.
Alamofire
This will help you send and receive http requests.
Swifty JSON
This will help with JSON parsing
However if your question is more regarding server side issues. You could look into a REST api and that way you could only request certain entities that you are interested in instead of just sending back the entire batch of information with all of your data, and searching through it on the iOS device.
Hopefully this is somewhat helpful.
If you are only planning on GET-ing some content from the web you can use the NSURL class. NSURL *lru = [NSURL URLWithString:#"http:mywebserver.com"] and then create a new string object from the url with [NSString stringWithContentsOfURL:lru], or any data you would like. If you are trying to hold a session or having more control over the request, I would suggest looking into the NSURLSession class.

Oauth library for iOS (in particular Yelp)

I want to add Yelp search into my application.
To do this I need to use Yelps Oauth authentication. This sounded easy as I've made some server applications before.
However, I keep getting an INVALID_SIGNATURE with the code I have created to make and retrieve data from a constructed URL.
I have checked the signature output by my app and it is exactly the same as the one they provide at http://api.yelp.com (I've even checked the two strings (before the hashing) at http://www.textdiff.com and they said they were the same)
It seems I hit a dead end and cannot get around this error.
Can anyone point me in the right direction with why my signature might not work
and/or
Can someone point me to a good iOS Oauth tutorial and library (any library I have found has poor documentation on how to use it)
Thanks

API to post on Tumblr

I've been trying to upload an image to Tumblr from my iOS application for a little while now, but I can't get my method to work properly.
My current method uses ASIHTTPRequest and OAuthConsumer according to this guide.
However, I end up getting a 401 error (Authentication needed).
You can find the explanation for my problem here.
But my question is : Is there any other mean/API to post on Tumblr for iOS?
I saw that OAuthConsumer was not fully functional on that side, and I didn't find anything with the GTM.
Thanks.
Finally found a solution to my problem a few time ago.
I first thought that it was a bit old and that it wouldn't work but in the end, implementing the TumblrUploadr did the thing.
To sum it all, I achieved login with GTM-OAuth and uploading with TumblrUploadr. For those who seek a solution to the Tumblr API.
Update : Some info concerning GTMOAuth, if you want to use the callback, you have to add a flag in the GTMOAuthAuthentication.m > +(NSArray*)tokenAuthorizeKeys : add kOAuthCallbackKey in the array so that it will be taken into account. Else, you have no callback.

Resources