I’m trying to implement TUS and according to this doc I can send requireSignedUrls and allowedOrigin options in Upload-Metadata header. https://developers.cloudflare.com/stream/uploading-videos/upload-video-file#supported-options-in-upload-metadata
I’ve tried sending like
Upload-Metadata: requiresignedurls, allowedOrigins=“abcd.com,efgh.com”
requiresignedurls works fine but not allowedorigins
Values need to be encoded in base64, so correct header would be:
Upload-Metadata: requiresignedurls,allowedOrigins=YWJjZC5jb20sZWZnaC5jb20=
Related
I'm able to get a list of gists and their files https://api.git.mygithub.net/users/myuser/gists?per_page=100&page=1 which I found using the docs here: https://docs.github.com/en/free-pro-team#latest/rest/reference/gists#get-a-gist
The files on the gist object have a raw_url. If I fetch the raw_url with the same token, it fails wanting me to authenticate. If I add the header: Accept: application/vnd.github.v3.raw it returns a 406 Not Acceptable. I've references to that header around.
I'm not sure what the scope should be on the token. It seems like it would be the same one I accessed the API. In the UI if you click the raw file it gets a token appended to the url. That token doesn't look like one of the Private tokens mentioned here: https://docs.github.com/en/free-pro-team#latest/github/authenticating-to-github/creating-a-personal-access-token
So what is the format of the HTTP request to download the raw gist?
The raw url needs to have the hostname of gist. changed to raw. and the url path needs to start with /gist/.
Example code in Go fixing it:
url := gistFile.RawUrl
url = strings.Replace(url, "gist.", "raw.", 1)
url = strings.Replace(url, ".net/", ".net/gist/", 1)
I’ve been working on a simple function with the serverless framework that gets some data in a http POST, does some analysis and sends the results back. I got it working locally on my machine using serverless-offline but when it comes to deploying it I’m getting an error parsing the event.body.
Logging out the event.body it’s a string that looks like this:
----------------------------267253304929569989286258
Content-Disposition: form-data; name="text"
TEST
----------------------------267253304929569989286258--
so it makes sense that the parse is failing but I have no idea why this error it happening.
Any suggestions? I’ve tried a bunch of different things but am completely stumped.
Thanks in advance!
You can't JSON.parse that event.body cause it isn't JSON. It looks like whatever POSTed that data is using a multipart form POST style request rather than sending JSON. How are you invoking the HTTP POST?
I had the same issue and after a lot of debugging noticed 2 important things:
1.When the content type is application/x-www-form-urlencoded you might need to parse the data in a different way:
const qs = require('querystring');
module.exports.run = async event => {
try {
const data = qs.parse(event.body);
console.info('DATA:', data);
} catch(e) {
console.error(e.message);
}
}
2.When the Content-Type of the request is multipart/form-data the parsing will be even more complicated. I will suggest extra dependency to parse it like multiparty or any other of your choice
Thank you #Brian Winant! I am putting the answer here as a screenshot so it's clearer. In Postman, do the following:
AWS Lambda would return event.body as encoded query strings if the content-type is x-www-urlencoded. To have it return a JSON string you can then parse, send JSON data and set content-type as application/json.
Via the Fogbugz REST API I try to get all articles with a certain tag. I wrote some code in python to get it but I got "zero" as result. Here is my code:
import requests
...
some code to log in
...
req_params={"cmd": "search", "token": self.token,"q":"tag:\"my_cool_tag\""}
response = requests.get(req_url, data=req_body, headers=req_header, params=req_params, verify=False)
print (response.text)
as response I got:
...cases count="0"...
Is there a way to get all articles with a certain tag in a list via REST-API and how I can achieve this?
I am using FogBugz Version 8.8.49.0.
Try the search with curl or directly in your web browser to check that it works, then see if you can debug your Python.
In a browser I can successfully query FogBugz Online with something like:
https://<domain>.fogbugz.com/api.asp?token=<token>&cmd=search&q=tag:%22<my_tag>%22
Although I entered quotes around my tag, the browser url encoded them to %22. Obviously <domain>, <token> and <my_tag> should be replaced with your own values.
Your basic parameters look OK, but I haven't used Python so am not sure whether escaping the quotes around the tag translates well to the GET request? Maybe try url encoding "my_cool_tag".
I want to upload logo image from http://werkzeug.pocoo.org/
After saving it I tried the following. I'm a noob so please help..
the received stream when i upload through a html forms is
'GIF89a\xa0\x00\xa0\x00\xe3\x08\x00\x01\x03\x00,)\x00JB\x00g`\x00\x96\x8a\x00\xcd\xbc\x00\xe9\xd5\x00\xfd\xeb\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff!\xf9\x04\x01\n\x00\x08\x00,\x00\x00\x00\x00\xa0\x00\xa0\x00\x00\x04\xfe\x10\xc9I\xab\xbd8\xeb\xcd\x11\xf8](\x8edi\x9e\xe8\xf4\xadi\xeb\xbep|\xad\xb4l\xdfx.\xd1\xbc\xee\xff#\x0eo\x18,\x1a}\xc3\xe4q\xc9l%\x05\xca\xa6t\xbaI\x12\x0eP"u\xcbM\x16\x0e\xe0l\x8fKfZ\xc1hq\xad\xcc\x06\x9e\xd1\xe9h{n{\xc3\xd1\x039}\x9f\xb2\xdf\xf1z|\x82"~\x7f\x80Z\x83\x89UCW\x86\x86y\x88\x8a\x92\x14\x85\x8ep\x90c\x93\x93\x95\x96\x97\x81\x9a|\x9c\x9d\x9e\x91\xa0tI\x03\xa3\xaa\x98k\xa6s\xa2\xaaw\x04\x9f\xaeT\xb0\xb1\xb2\xb4\xb5fC\xa9\xb8\xb1\x06\xb3\xa5\xbbK\xa8\xbf\xc7\xc2\x99\xc4G\xc6\xc7\xc8\xba\xcb9\xcd\xce\xcf\xc3\xd18\xd3\xd4\xd5\xca\xd77\xd9\xda\xdb\xad\xdd2\xdf\xe0\xe1,\xe31\xe5\xe6\xe7 \xe9.\xa8\x06\xec\xec\xc9\xe2\xef%O\xf3\xfa\xf5\xe8\xf7$\xf9\xfa\xf6A\xf37c\x88\x00y\x01\xf5\x15\x18HP\x85A\x84\t\x152$\x080b\xc2\x85\xd6\x1az0h\xb1#Fn\xfe\x1a\x9f#\xecxq\xe2\xb5$\x01F\x92,\x99q\x1c\xca\x950?\xdaK\'\x12fL\x93\xa6P\xaa\xb4i\xd1\x00\xceMCR\xf2\xe4\xe9\xb3e\xce\xa0;\x87z\x0c`\x14(\x0f\xa1J\x87\x16`\n\x12\x94\xce\xa8Qe\xf6;\xfa4)\xd6\x95S\x9b\xeeI\x02\xc0k#\x03\xc1\x08\x0c\x10\xc0v\x00\x81\x02f\x15R\x9d9\xe8\xea\xca`n\xd5\xe6\x1d\xc0T\xad\x00\x02q\xcd\x85\xad:\xd6K\xcc\x00\x7f\xbf\x1c0P`\xc0\x80`l\xdf\xaa\xbd;wk(\xa4D\x19;\x06\x8c\x86\x00`\x01\x01\xd62}\xdc\xd1#ew\x97\x87(\xc6\xba\x90\xf3\x81\xa9P\x19\xabu\x1d\xf14\x80\xd4<\x02\x83\x05 \x00\x0c\x81\x83\x86\x1a\x93d\x85\x9a\r\xca\xd5_\xc1,l\xdc\xdb\x92\xf0\x8e\xc4o\x1b7\x9c<\x97/G\xf2<\x93$p\xba\x0cY\xddC\'[\x82\xe8v{\xf7-d\x91WG\x13\x00\xaa\xa3\xd5\x02\xd4\x07\xe4N\xb8H\xfa\xf5\x7fL\xf3\xee\xc4\x18\x8c\x01\xe0\xd0\x89\xfe%\ru\xf8\xdd\x81\xd1u\xc1y\xe6\x19\x80\x16E\xc7\x8bj\x05:"L#\xef\xd1\x80`B\xff\t\xa8\x0e\x81\x11\xfe\x91\x85|p\xd4CaD\x19\xd6W\xc7-\x11~\x14\x97l\xdc\xdd\xa5Fq\x03B\xd8\xa1%\xc90\xd8\xc9\x85\x16\xbd(]\x8c<\x8c8c.\x16:\xa7 \x8e9j\x88\x0f\x87?\xc2\xa1\xd5\x07\x17\x06\x83\xc6T\xe0\xb1\xa3\xa37(FX\x94\x1d\xfaQh\x00i<9\xb8!#I\x1a\xc2\x0f\x84W\x96\xe5\x1fwk\xf9\xd8\xa0\x91\x8b\x80\x19&\x90dQ\xc5\xcfc\xffq6\x8b\x9a\x11y\xd9\x07\x92o\x8eI\xc3\x17~\xb9%F\x1eZ\x8ef\x93\x9e&\x90\x85g\x92~\xae#$\x16447[Z\x87\xb2II\x95\x056\xca\xe4x\x95\t0\x80b\xf2<\x9a\x10\xa2!(\xfa&\x9c/uR\x8f\x8d\x07,\x9a\'\x9b\xa6\x9ezH\x9c\x81a\xe2\xde\x99J\x91\x9a\x01Y\xa2\xce\xa8\xe9\x07 \xde\x81\x89|\xb4\xf14\xa6\x10\x98\xae\x17\x0cY+\xfe\xb8\n\x87~\x01\xfc\xf1\xa99Qvf\x94\xa2\xd5&\x17]\x8f\xbf,\xd4\\g\xce\x8e\xb2P*\xd5\xea\xba\xc3:In\x1b\xe43\x08\x05\x13l,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\x9f\xfc\xf1\xe8G\x9f\xa6\xd2c\xd8,>\x12\x9d\x85I\xcd5S\x9a\xf2\xe0\xa2\xcfb\xc4\xf2ZuF\x9e\xf6\xd4\xa7!\xa5\x860T\x96<\xa3\x1e\x15\xa9\x7f\xc3\x85i|!\xa7\xd3\xb8OX\x14\xf5G\xb2<\xf6\xbc\x03it\xa7Y\r\xa8\xf5\xc4U\x19\xb5\x00\xeb5\xa0\x01\x99S\x9fz\xb7\xa4\x8eGi\x9c\x04\xe7(\xd6\xca\xd6\xb6F\x95\xac\xc53 J\xeb*\xb8\xbc\xe6G\x8a\xa9\x14\x18_\xd5W\xd3\xf7\x80P\xada\xad+\xba\x1c\xc1\x17\xdd\x08v\xb0(t\xab#\xf6\n\xd9\xd4\xa9.!\x8f\xad\xac\x13\xfc\xda\x0e\xcd\x92\x83\xb3\x01K\xacgA\xea(sdv\xb4/X\xac\xaaD\x8b\xdaK]\xf6\x17\xa7m-\x0c*R?\xca\xca\x96\xb0\xf8k\x1ako\xdb\xb5\r\xfeaI\xbc\xfdAM\x1cF\x97\xe0\x9eH\x88\xcf\x02\xaeq\xdd0\xb0A\xe5.\x97\xb9\xc8u\xees\xa1k5\xe9N\x97\xbaX\xdb\xedu\x915\xb1\xedZQ\xbb\xde\xdd\\\r\xc3;[\xdb\x92\x17\x1b\xe3<\xaf\x11\x16\x1a\x8d\x08\x00\x00;'
I receive the above using req.file["name"] and store it in the Mysql.
now when i read back from MySQL I get,
u'GIF89axa0x00xa0x00xe3x08x00x01x03x00,)x00JBx00g`x00x96x8ax00xcdxbcx00xe9xd5x00xfdxebx00xffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxffxff!xf9x04x01\nx00x08x00,x00x00x00x00xa0x00xa0x00x00x04xfex10xc9Ixabxbd8xebxcdx11xf8](x8edix9exe8xf4xadixebxbep|xadxb4lxdfx.xd1xbcxeexff#x0eox18,x1a}xc3xe4qxc9l%x05xcaxa6txbaIx12x0eP"uxcbMx16x0exe0lx8fKfZxc1hqxadxccx06x9exd1xe9h{n{xc3xd1x039}x9fxb2xdfxf1z|x82"~x7fx80Zx83x89UCWx86x86yx88x8ax92x14x85x8epx90cx93x93x95x96x97x81x9a|x9cx9dx9ex91xa0tIx03xa3xaax98kxa6sxa2xaawx04x9fxaeTxb0xb1xb2xb4xb5fCxa9xb8xb1x06xb3xa5xbbKxa8xbfxc7xc2x99xc4Gxc6xc7xc8xbaxcb9xcdxcexcfxc3xd18xd3xd4xd5xcaxd77xd9xdaxdbxadxdd2xdfxe0xe1,xe31xe5xe6xe7 xe9.xa8x06xecxecxc9xe2xef%Oxf3xfaxf5xe8xf7$xf9xfaxf6Axf37cx88x00yx01xf5x15x18HPx85Ax84\tx152$x080bxc2x85xd6x1az0hxb1#Fnxfex1ax9f#xecxqxe2xb5$x01Fx92,x99qx1cxcax950?xdaK\'x12fLx93xa6Pxaaxb4ixd1x00xceMCRxf2xe4xe9xb3excexa0;x87zx0c`x14(x0fxa1Jx87x16`\nx12x94xcexa8Qexf6;xfa4)xd6x95Sx9bxeeIx02xc0k#x03xc1x08x0cx10xc0vx00x81x02fx15Rx9d9xe8xeaxca`nxd5xe6x1dxc0Txadx00x02qxcdx85xad:xd6Kxccx00x7fxbfx1c0P`xc0x80`lxdfxaaxbd;wk(xa4Dx19;x06x8cx86x00`x01x01xd62}xdcxd1#ewx97x87(xc6xbax90xf3x81xa9Px19xabux1dxf14x80xd4<x02x83x05 x00x0cx81x83x86x1ax93dx85x9a\rxcaxd5_xc1,lxdcxdbx92xf0x8exc4ox1b7x9c<x97/Gxf2<x93$pxbax0cYxddC\'[x82xe8v{xf7-dx91WGx13x00xaaxa3xd5x02xd4x07xe4Nxb8Hxfaxf5x7fLxf3xeexc4x18x8cx01xe0xd0x89xfe%\ruxf8xddx81xd1uxc1yxe6x19x80x16Exc7x8bjx05:"L#xefxd1x80`Bxff\txa8x0ex81x11xfex91x85|pxd4CaDx19xd6Wxc7-x11~x14x97lxdcxddxa5Fqx03Bxd8xa1%xc90xd8xc9x85x16xbd(]x8c<x8c8c.x16:xa7 x8e9jx88x0fx87?xc2xa1xd5x07x17x06x83xc6Txe0xb1xa3xa37(FXx94x1dxfaQhx00i<9xb8!#Ix1axc2x0fx84Wx96xe5x1fwkxf9xd8xa0x91x8bx80x19&x90dQxc5xcfcxffq6x8bx9ax11yxd9x07x92ox8eIxc3x17~xb9%Fx1eZx8efx93x9e&x90x85gx92~xae#$x16447[Zx87xb2IIx95x056xcaxe4xx95\t0x80bxf2<x9ax10xa2!(xfa&x9c/uRx8fx8dx07,x9a\'x9bxa6x9ezHx9cx81axe2xdex99Jx91x9ax01Yxa2xcexa8xe9x07 xdex81x89|xb4xf14xa6x10x98xaex17x0cY+xfexb8\nx87~x01xfcxf1xa99Qvfx94xa2xd5&x17]x8fxbf,xd4\\gxcex8exb2P*xd5xeaxbaxc3:Inx1bxe43x08x05x13l,x1fxf5*xe60xbcxcaxeax9fx8e<|{x0c_x9bxb1xf3x11xabxb1x1cxebP/xf6.x86/\rxb7xae\'ggxefxce;Fxbdxf6x96xc8xacx99)xaex80x900\r{8xf1xbaxb2xeaxb7qxc6xb9xaexe0xdf\\ x83xa1.xc1x11xdbxe6&~hxb5xdaxacrx7fxaexa2x04Gx1d{<qxb8D!xf6x1a\rx8d#x92xb0xb4rxacx1cfx99xccxea[x9dxc7xbdxb1xd2x9exc5xa3xf8Yx01xcaIx0e6xb1xd1GGjxf3\nx01xb8x8ax96xd3x16x08]xf1xc6x1fdxdbx93x7fV+x9dxf1xb6xbbxf2 xafRK~Wxa0ixc0xc9Dxaeg sx9d6xc7xebxb5x9d,IHx93xfd2.vkx00xf5Wx8cx81xfdx01xce6xc9xd4xdcxbfx80xff4xTxbfxe2x9dxdcx7fxcbxae xa9xc8xfexaax04xdexc1xe3<xe9xfdx10xcbTx15nxf9x96x1fPxfdx87xe6xa5xaa\rxb9xe1x00xfcx1cx95xc7xbe4x1ax18xeax84xa8-xb63x9ex0fqxfbYTxa5R#ocx86Kxfbx08x9cx93xc8:x00%xf3xddxbbxcbxfb\rx16#xc6xc3xffx93/L\'sx8bxdfxa0xc9|!Ox01 xb7xfdxa5xe5|xb3x8e8xdfox19x96Gxc9xd1x9fxf0xb9xf1`x9bxaeTx86xe5xf3|x80xcfx99xffDxfcxf4xecOxbdxfb<6x03fxa1xcfx81xf1x1ex8fJxb7xbfGLxccuCxb9x9axef03x1ex01xea`}x12xa1x95xb2Nxe3x8b2!xf0Ixf6Cx01x04xe7xd1xa8xe4xf5x84*xa1xd9xd4b0rAx98YjOVxbbx88x18Bxc32x12x92x0ex00xe4\nxcdxefx02x98Axxe4xabx80x1d;xc8x0cxe7xc7$xd8xa9xc2x81xccxb8axc1x9cx91%Rx80xe6x03%xdcxd9\txbfGxc0!xfe"x0bx08"Nx12x89x06xa3x07a\rx87?xcax82xfexbex94Fxc3%R\taXdxd9cx92x11"xacexecjUx9cx02x03x9dxx07h]xc9-x17kx9dnxa6xd4x865xb21x0cX;Mhxe8xa6\n:xbexa2+wxc4xe0xc6x92xf8;/x06xc1x8ex05xa3x1bxd1x8ex88xc4x00xda&x11H\txa3x8bx9a%x93x940\'cRxb3x0cnx1ax99xb2xdcXx10<x99Lxe3&xc3v*4x9aIqxaa0%Wbx96$x8f}xe6px80)xcax14x1fxe9x8axa0xxd0&6xfbx82xd2xdex02xb06xd2xb2x16Ix90$xb5xxd8xac*xa9rx19xc1|x1bb^x885xfaxb4xeex8cxbfDxa6x8c&xb70Vxf4lx96x86<xc54_xb7<]xcao1xa3x90x98&xa3xc1\'x98xf4mx16xa9xb0f*xfdxf8x0exc3x08x13;Txe9x8dx8ax889Evxdexa3x9c$xaaxc7xb0xe6xb7xa5xe7xa9"x9ax14Qxcd;x9fx85x98xe0xf10%x81x11xa7(xefxb9Mx0cexc13Ax02`x1fxfexb3xb9xcax15xdcx12x17x98`^xe9x90xF{jd`xdfxd4Gxcb|xc8x8f$BxcaD!xf1x9a6x8axf8x91+$xc3x9fxfcxf1xe8Gx9fxa6xd2cxd8,>x12x9dx85Ixcd5Sx9axf2xe0xa2xcfbxc4xf2ZuFx9exf6xd4xa7!xa5x860Tx96<xa3x1ex15xa9x7fxc3x85i|!xa7xd3xb8OXx14xf5Gxb2<xf6xbcx03itxa7Y\rxa8xf5xc4Ux19xb5x00xeb5xa0x01x99Sx9fzxb7xa4x8eGix9cx04xe7(xd6xcaxd6xb6Fx95xacxc53 Jxeb*xb8xbcxe6Gx8axa9x14x18_xd5Wxd3xf7x80Pxadaxad+xbax1cxc1x17xddx08vxb0(txab#xf6\nxd9xd4xa9.!x8fxadxacx13xfcxdax0excdx92x83xb3x01KxacgAxea(sdvxb4/XxacxaaDx8bxdaK]xf6x17xa7m-x0c*R?xcaxcax96xb0xf8kx1akoxdbxb5\rxfeaIxbcxfdAMx1cFx97xe0x9eHx88xcfx02xaeqxdd0xb0Axe5.x97xb9xc8uxeesxa1k5xe9Nx97xbaXxdbxedux915xb1xedZQxbbxdexdd\\\rxc3;[xdbx92x17x1bxe3<xafx11x16x1ax8dx08x00x00;'
All the escape characters are gone now, i want to display this file and i'm not able to on the HTML after i send a response.
Why is this happening and how can I fix this ? I'm not able to get through this for more than a week.
I'm using python2.7.3 and werkzeug and mysql-connector for python.
The example code in one of the github uses this
'R0lGODlhoACgAOMIAAEDACwpAEpCAGdgAJaKAM28AOnVAP3rAP/////////\n//////////////////////yH5BAEKAAgALAAAAACgAKAAAAT+EMlJq704680R+F0ojmRpnuj0rWnrv\nnB8rbRs33gu0bzu/0AObxgsGn3D5HHJbCUFyqZ0ukkSDlAidctNFg7gbI9LZlrBaHGtzAae0eloe25\n7w9EDOX2fst/xenyCIn5/gFqDiVVDV4aGeYiKkhSFjnCQY5OTlZaXgZp8nJ2ekaB0SQOjqphrpnOiq\nncEn65UsLGytLVmQ6m4sQazpbtLqL/HwpnER8bHyLrLOc3Oz8PRONPU1crXN9na263dMt/g4SzjMeX\nm5yDpLqgG7OzJ4u8lT/P69ej3JPn69kHzN2OIAHk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x7VpRu97dXA3DO1vbkhcb4zyvERYajQgAADs\n='
This works perfectly and its all normal text.. how can i get this one. ?
I found what was wrong, For anyone with the same problem.. File upload sends in hex format or raw strings when received. The uploaded file stream needs to be Encoded with 'base64' and stored in mysql. Mysql tries to remove the escape characters when trying to store the raw strings so the stream needs to be encoded.
req.file.stream.read().encode('base64')
when sending the file to the client decode and set the mime type of the content as response.
This solved my issue.
I'm using the MediaWiki API to update some pages with an experimental robot.
This robot uses the Java Apache HTTP-client library to update the pages.
(...)
PostMethod postMethod = new PostMethod("http://mymediawikiinstallation/w/api.php");
postMethod.addParameter("action","edit");
postMethod.addParameter("title",page.replace(' ', '_'));
postMethod.addParameter("summary","trying to fix this accent problem");
postMethod.addParameter("text",content);
postMethod.addParameter("basetimestamp",basetimestamp);
postMethod.addParameter("starttimestamp",starttimestamp);
postMethod.addParameter("token",token);
postMethod.addParameter("notminor","");
postMethod.addParameter("format","xml");
int status = httpClient.executeMethod(postMethod);
(...)
However the 'content' string contains some accents. System.out.prinln(content) looks OK, but the accentuated characters in the wiki look bad. E.g. 'Val�rie' instead of 'Valérie'.
How can I fix this?
OK, changing the request header fixed the problem.
postMethod.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
In my PHP code to talk to the Mediawiki API I used urlencode to encode the title parameter, and this seems to work fine.