The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. February 11, 2012, 02:31:55 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Image transfer API  (Read 549 times)
kurdt
Lifer
*****
Offline Offline

Posts: 1153


paha arkkitehti


View Profile
« on: February 26, 2010, 12:20:43 AM »

I have to build API that you can use to send images. Now what's the best way to do this? I was thinking about doing just plain old POST API. Is there any standards how this should be done? I would prefer solution that doesn't involve huge libraries that API users have to download. In perfect world it would be native PHP functions and maybe CURL.

My first idea was to just to base64_encode() the image and send it as normal POST variable but base64_encode() adds about 33% more to the size. This starts to add up when you have image repository where photographers send big images and A LOT of them. So is there another more lightweight way to do this?
Logged

I met god and he had nothing to say to me.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #1 on: February 26, 2010, 12:30:40 PM »

"send images..."

I'm not sure what your intention is. You talk about about POSTs but sending and an API. And this topic is in PHP. So I assume it's a server-side solution. I'm not sure I understand why you'd not just let Apache deliver things upon request ... but clearly that's because I don't understand what you want  ROFLMAO
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
kurdt
Lifer
*****
Offline Offline

Posts: 1153


paha arkkitehti


View Profile
« Reply #2 on: February 27, 2010, 12:43:25 AM »

"send images..."

I'm not sure what your intention is. You talk about about POSTs but sending and an API. And this topic is in PHP. So I assume it's a server-side solution. I'm not sure I understand why you'd not just let Apache deliver things upon request ... but clearly that's because I don't understand what you want  ROFLMAO
Hehe, sorry for not explaining myself clear enough, happens quite often :/

Anyway, the idea is simple: User has a script that sends image files from computer A to computer B.

So what I was thinking was that I could just do API that accepts POSTs. So you could do $post = array('user_id' => 'f00', 'api_key' => '0F0F', 'image' => base64_encode($imagefile)); and then just send it forward as POST with CURL. But I'm not sure if this is the best day to do it. Everybody seems to be saying that I should do RESTful API but I haven't ever done one and I'm not sure it's worth the hassle when I just need to get this done asap.
Logged

I met god and he had nothing to say to me.
DangerMouse
Expert
****
Offline Offline

Posts: 238



View Profile
« Reply #3 on: February 28, 2010, 10:54:33 AM »

I'm not sure I'm following the requirements exactly, but a RESTful API is just one that uses standard HTTP request methods to instigate action, in this instance POST is appropriate because its telling the recipient to "create" a resource i.e. the image being sent.

DM
Logged
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #4 on: March 01, 2010, 02:39:12 PM »

You won't be able to transfer a file with a regular form POST either. You need to use multipart or you're not getting anything that's of a binary MIME type across.

Otherwise, have the server pull it from the client.
Logged

hai
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!