Skip to content

Instantly share code, notes, and snippets.

@rambabusaravanan
Created March 17, 2018 22:07
Show Gist options
  • Save rambabusaravanan/22a481bf2a8ca6c35e06dcd42c64ef2b to your computer and use it in GitHub Desktop.
Save rambabusaravanan/22a481bf2a8ca6c35e06dcd42c64ef2b to your computer and use it in GitHub Desktop.
Upload Service

The various approach followed for upload service

@rambabusaravanan
Copy link
Author

Upload Url
https://discussions.udacity.com/uploads.json?client_id=xxx&authenticity_token=xxx

Content-Type
multipart (name="files[]")

Response

{
  "id":557993,
  "url":"/uploads/default/original/4X/1/d/2/1d2e40234838bfa0f4eb0edb53fe3f94a219ff1c.png",
  "original_filename":"Screenshot from 2018-03-18 03-31-31.png",
  "filesize":60165,
  "width":690,
  "height":419,
  "extension":"png",
  "short_url":"upload://4a8W9xc0IkpfrPuqvEeFKWXGaZe.png",
  "retain_hours":null
}

File Url
https://discussions.udacity.com/uploads/default/original/4X/1/d/2/1d2e40234838bfa0f4eb0edb53fe3f94a219ff1c.png

@rambabusaravanan
Copy link
Author

rambabusaravanan commented Mar 21, 2018

Behance: Avatar Upload API

Request Url
POST https://www.behance.net/v2/profile/avatar

Content-Type
multipart/form-data (crop_x, crop_x2, crop_y, crop_y2, qquuid, qqfilename, qqtotalfilesize, image)

Response

{
    "http_code": 200,
    "images": {
        "100": "https://mir-s3-cdn-cf.behance.net/user/100/644c3055358245.5ab29fb938759.jpg",
        "115": "https://mir-s3-cdn-cf.behance.net/user/115/644c3055358245.5ab29fb938759.jpg",
        "138": "https://mir-s3-cdn-cf.behance.net/user/138/644c3055358245.5ab29fb938759.jpg",
        "230": "https://mir-s3-cdn-cf.behance.net/user/230/644c3055358245.5ab29fb938759.jpg",
        "276": "https://mir-s3-cdn-cf.behance.net/user/276/644c3055358245.5ab29fb938759.jpg",
        "50": "https://mir-s3-cdn-cf.behance.net/user/50/644c3055358245.5ab29fb938759.jpg"
    },
    "updated": 1
}

Replace Upload
All versions of images are retained
Image URL varies as https://mir-s3-cdn-cf.behance.net/user/100/68584055358245.5ab2a2cb0101a.png

404 Response
https://mir-cdn.behance.net/v1/rendition/user/125/644c3055358245.5ab29fb938759.jpg

{ "http_code": 404 }

@rambabusaravanan
Copy link
Author

Pre-Upload Url
GET https://www.linkedin.com/voyager/api/fileUploadToken?type=ATTACHMENT

Response

{"uploadToken":"OhRHSvT03g5tq..some.token.around.360chars..eIEdn5Ta55yZ"}

Upload Url
POST https://www.linkedin.com/mupld/attachment
Content-Type: multipart/form-data (file, sign_response, persist, callback, csrfToken, persist, upload_info, file)

Response

{
  "sig":"0AQGDEqsBkyZbnBrg_DJByO9SmVE88oo--6U",
  "filename":"hello.pdf",
  "value":"\/AAMAAwDGAAQAAQAAAAAAABHcAAAAJDBmZjFmY2MyLTZmYjYtNGE4OS1iM2YwLWYyMzBjMDA3NjRmOA.pdf",
  "status":"SUCCESS"
}

@rambabusaravanan
Copy link
Author

GitLab

Temp Url
https://gitlab.com/uploads/tmp/1518381932-32940-0001-7618/1.svg

Img Url
https://gitlab.com/uploads/-/system/group/avatar/1066797/first.png
https://gitlab.com/uploads/-/system/group/avatar/1066797/second.png
https://gitlab.com/uploads/-/system/group/avatar/1066797/*

URL Pattern
https://gitlab.com/uploads/-/system/group/avatar/{userid}/filename.ext

Notes
Request Pattern: Single request on final submit -> file + other data in multipart, not json
History Pattern: old image not retained, but the "filename.ext" seems to be any dummy name

@rambabusaravanan
Copy link
Author

rambabusaravanan commented Apr 4, 2018

Flock (profle pic)

Notes
On button click, two APIs are sequentially executed. One for media upload, other for other data updates.

Upload Service
POST https://fs.go.to/filesharing/profile_image?token=u6khmkkjmhkunfxxxxxh8l6nfy8fu6mj&guid=rgr966r94wg4rwlg
Content-Type: multipart/form-data (file)

Response Data

{ "version":3, "url":"https://i.flockusercontent2.com/rgr966r94wg4rwlg?r=1155099828" }

Update Profile Service
POST https://proxy.handler.talk.to/go.to/fzeus/v5.0/updateProfile?token=u6khmkkjmhkunfxxxxxh8l6nfy8fu6mj&guid=rgr966r94wg4rwlg
Content-Type: application/json

Request Data

{
  "name": { "firstName":"Ram Babu", "lastName":"S" },
  "mobile":"+917373980000"
}

Response Data

{
  "emails": [ { "email":"[email protected]", "isVerified":true } ],
  "mobiles": [ {"countryCode":"+91", "mobile":"7373980000", "isVerified":false } ],
  "locale":"en-US",
  "guid":"rgr96xxxxxg4rwlg",
  "version":5,
  "preferences": { "timezone": { "value":"+05:30", "isPublic":true } },
  "name": { "firstName":"Ram Babu", "lastName":"S" },
  "imageUri":"https://i.flockusercontent2.com/rgr966r94wg4rwlg?r\u003d1157408321"
}

@rambabusaravanan
Copy link
Author

POST: https://addons.mozilla.org/en-US/firefox/users/edit
Content-Type: multipart/form-data (csrfmiddlewaretoken, username, email, ..., photo)
Response: HTTP 302 (empty response)

Location: https://addons.mozilla.org/en-US/firefox/users/edit (GET)
Notes: GET is the page request, POST is the api request with 302 of same url (refreshes the page once api is success)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment