question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue uploading using __upload POST method.

See original GitHub issue

Here is source code for test.py Using python 2.7, have tried without x-mtok and with.

var2 = 'some\\path\\with\\stuff\\'
for file in os.listdir(var2):
	filepath = var2+file
	print('output_file',var2+file)
	sys.stdout.flush()

	#get file info
	fileId = str(uuid.uuid4())
	fileSize = str(os.path.getsize(filepath))
	print 'got file info. fileId: '+fileId+' fileSize: '+fileSize
	#send meta data to POST
	print 'sending meta data and first byte'
	headers = {"x-mtok": "x5PfcjwqDhG39xBTE", "x-start": "1"}
	body = {"fileId": fileId, "chunkSize": fileSize, "fileLength": "1"}
	body["file"] = {"name": file, "type":"text/plain", "size": fileSize, "meta": {}}
	r = requests.post("http://localhost:3000/cdn/storage/Output/__upload", headers=headers, json=body)
	print r.status_code
	time.sleep(.2) #idk some time
	#send chunks to POST
	print 'sending chunk 1/1'
	headers = {"x-mtok": "x5PfcjwqDhG39xBTE", "x-fileid": fileId, "x-chunkid": "1", "content-type": "text/plain"}
	with open(filepath, "rb") as upload_file:
	    data = base64.b64encode(upload_file.read())
	r = requests.post("http://localhost:3000/cdn/storage/Output/__upload", headers=headers, data=data)
	print r.status_code
	time.sleep(.2)
	#send eof byte
	print 'sending eof byte'
	headers = {"x-mtok": "x5PfcjwqDhG39xBTE", "x-fileid": fileId, "x-eof": "1", "content-type": "text/plain"}
	r = requests.post("http://localhost:3000/cdn/storage/Output/__upload", headers=headers)
	print r.status_code

Using python 2.7, have tried without x-mtok and with it. The file interestingly enough shows up in the Output collection’s storagePath parameter, but it doesn’t seem to be added to the collection. This I assume happens after the eof is recieved which doesnt seem to be getting a response.

Python log:

got file info. fileId: 51c1cf70-ff3f-4420-b86f-4cc1c0076a89 fileSize: 35487
sending meta data and first byte
204
sending chunk 1/1
204
sending eof byte
Traceback (most recent call last):
  File "test.py", line 38, in <module>
    r = requests.post("http://localhost:3000/cdn/storage/Output/__upload", headers=headers)
  File "C:\Python27\lib\site-packages\requests\api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 490, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))

Meteor Server Log:

=> Started proxy.
=> A patch (Meteor 1.5.4.1) for your current release is available!
   Update this project now with 'meteor update --patch'.
=> Started MongoDB.
I20180116-15:12:14.122(-6)? [FilesCollection.storagePath] Set to: C:\Users\Admin\Desktop\Agricultural ML stuff\ES-Web-Storage\Output
=> Started your app.

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

I20180116-15:12:22.243(-6)? [FilesCollection] [find({}, undefined)]
I20180116-15:14:22.819(-6)? [FilesCollection] [File Start HTTP] LIDAR_Width_Avg_1.7000000000000002_inches.jpg - 51c1cf70-ff3f-4420-b86f-4cc1c0076a89
I20180116-15:14:22.821(-6)? [FilesCollection] [Upload] [HTTP Start Method] Got #-1/1 chunks, dst: LIDAR_Width_Avg_1.7000000000000002_inches.jpg
I20180116-15:14:24.046(-6)? [FilesCollection] [Upload] [HTTP] Got #1/1 chunks, dst: LIDAR_Width_Avg_1.7000000000000002_inches.jpg
I20180116-15:14:25.255(-6)? [FilesCollection] [Upload] [HTTP] Got #-1/1 chunks, dst: LIDAR_Width_Avg_1.7000000000000002_inches.jpg

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
out0manacommented, Jan 17, 2018

sent PR

1reaction
oewaycommented, Jan 16, 2018

Hi guys, I am not using meteor at the moment, but I would also suggest that to look at the py-files project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

POST method uploads - Manual - PHP
POST method uploads ¶. This feature lets people upload both text and binary files. With PHP's authentication and file manipulation functions, you have...
Read more >
Post method does not maintain uploaded file if changing any ...
This issue has been observed in the latest version of postman. In earlier version of postman, it was maintaining the provided input file....
Read more >
How to Fix Image Upload Issue in WordPress (Step by Step)
First, connect to your website via FTP and then go to /wp-content/ folder. Inside, you'll find the uploads folder, which is where WordPress ......
Read more >
How to upload file with python requests? - Stack Overflow
Following is an example with using Flask file uploads. @app.route("/upload", methods=['POST']) def upload_file(): from werkzeug.datastructures import ...
Read more >
Common uploading errors - YouTube Help - Google Support
If you're having problems uploading your video, select the error message you're seeing and follow the troubleshooting steps to solve your issue.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found