Jasonette / Jasonette/JASONETTE-iOS
Support upload of arbitrary files via multipart HTTP request
- Dominant language
- JavaScript
- Stars
- 5.2k
- Forks
- 347
- PR merge metrics
- No merged PRs in 30d
Description
I have created a code sample by removing some code (not the correct way) to support multipart HTTP requests for one of my first jsonette apps
The JSON app is like this - it's based on the S3 Upload example, but because the normal upload requires only one request it's simpler, as there is no signign request, the server accepts any requests for file upload at the moment, simple logic
```js
{
"$jason":{
"head":{
"title":"IPFS Upload App",
"actions":{
"$load":{
"type":"$media.camera",
"options":{
"quality":"0.2"
},
"success":{
"type":"$network.upload",
"options":{
"url":"https://localhost:3000/ipfs_add",
"method":"post",
"content_type":"image/jpeg",
"data":"{{$jason.data}}"
},
"success":{
"type":"$render"
}
}
}
}
},
"body":{
"sections":[
{
"items":[
{
"type":"label",
"text":"Image uploaded"
},
{
"type":"label",
"text":"Refresh",
"action":{
"type":"$reload"
}
}
]
}
]
}
}
}
```
code in my fork that works with the client code:
https://github.com/Jasonette/JASONETTE-iOS/compare/develop...makevoid:simple-upload-sample-code2#diff-8da86b4d62074b49c79b7262005abd78R458
(not the ideal implementation - just for sample)
---
the server just reads the body and saves it locally so you can verify that the file has been uploaded
---
2 messages from jasonette slack
@gliechtenstein : ...instead of the current code where it uses https://github.com/Jasonette/JASONETTE-iOS/blob/develop/app/Jasonette/JasonNetworkAction.m#L45
@gliechtenstein : ....the only difference would be these lines
so, look at the additional attribute for $network.request, and if we need to upload, then we use the `POST:constructingBodyWithBlock` instead of `POST:parameters:progress`
and leave the `$network.upload` reserved for all advanced upload requests that involve not just uploading but also getting signed urls (for any cloud services, not just s3, but maybe azure, dropbox, etc.)
---
I +1 this for a standard implementation that supports a custom upload, maintains the s3 implementation which is cool but also some doc will be good for other providers/implementations like rackspace, drobpox, box, mega, hubic, sync, drive, ipfs, torrent, spideroak, etc maybe as cocoapods plugins in the future...
Contributor guide
Research direction
Start in app/Jasonette/JasonNetworkAction.m at the existing request construction, then compare the linked fork's multipart implementation. Use the sample JSON and the requested $network.request behavior as references; done means arbitrary files can be uploaded through a multipart HTTP request while the existing $network.upload flow remains available for advanced uploads.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, objective-c
- Domain
- mobile, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100