upload

How do I HTTP post stream data from memory in Ruby?

心不动则不痛 提交于 2019-12-04 03:19:49
问题 I would like to upload data I generated at runtime in Ruby, something like feeding the upload from a block. All examples I found only show how to stream a file that must be on disk prior to the request but I do not want to buffer the file. What is the best solution besides rolling my own socket connection? This a pseudocode example: post_stream('127.0.0.1', '/stream/') do |body| generate_xml do |segment| body << segment end end 回答1: Code that works. require 'thread' require 'net/http' require

Provide a callback URL in Google Cloud Storage signed URL

假如想象 提交于 2019-12-04 03:12:57
When uploading to GCS (Google Cloud Storage) using the BlobStore's createUploadURL function, I can provide a callback together with header data that will be POSTed to the callback URL. There doesn't seem to be a way to do that with GCS's signed URL's I know there is Object Change Notification but that won't allow the user to provide upload specific information in the header of a POST, the way it is possible with createUploadURL's callback. My feeling is, if createUploadURL can do it, there must be a way to do it with signed URL's, but I can't find any documentation on it. I was wondering if

Multiple file upload DRF

微笑、不失礼 提交于 2019-12-04 02:48:35
I have a requirement which I would like to allow multiple files to be uploaded within the same post request to create an object. I currently have a method of doing this, but after looking at some other examples it doesn't appear to be intended way to do it. models.py class Analyzer(models.Model): name = models.CharField(max_length=100, editable=False, unique=True) class Atomic(models.Model): name = models.CharField(max_length=20, unique=True) class Submission(models.Model): class Meta: ordering = ['-updated_at'] issued_at = models.DateTimeField(auto_now_add=True, editable=False) completed =

Large Base64 uploads in iOS

心不动则不痛 提交于 2019-12-04 02:48:02
Description: I need to send a base 64 encoded string in a HTTP POST parameter that represents a file to be uploaded. Current method: I'm using a ASIFormDataRequest and encoding my file into a base64 string like so: NSData *data = [[NSFileManager defaultManager] contentsAtPath:@"my path here"]; NSString *base64Data = [data encodeBase64ForData]; However when uploading large files the App runs out of memory and dies a horrid death! Proposed solution: Does anybody now how I would go about, say, reading the file from disk, converting it to base64 strings in chunks and attaching the converted base64

Django upload file into specific directory that depends on the POST URI

无人久伴 提交于 2019-12-04 02:44:20
I'd like to store uploaded files into a specific directory that depends on the URI of the POST request. Perhaps, I'd also like to rename the file to something fixed (the name of the file input for example) so I have an easy way to grep the file system, etc. and also to avoid possible security problems. What's the preferred way to do this in Django? Edit: I should clarify that I'd be interested in possibly doing this as a file upload handler to avoid writing a large file twice to the file system. Edit2: I suppose one can just 'mv' the tmp file to a new location. That's a cheap operation if on

not able to save 2 files from 1 form in codeigniter

无人久伴 提交于 2019-12-04 02:15:41
问题 I have a form that requires a user to upload 2 files, file-upload & imgupload . I am trying to save the entire form through ajax. Form and ajax code <form enctype="multipart/form-data" id="data"> <input type="file" id="file-upload" class="file-upload" name="file-upload" > <input type="file" id="imgupload" class="imgupload" name="imgupload" > <button type="submit" id="save" class="save-icon-btn"> <img src="<?php echo base_url(); ?>assets/img/Save.png"> </button> </form> $("#save").click

Should I check the response of WebClient.UploadFile to know if the upload was successful?

早过忘川 提交于 2019-12-04 02:03:42
I never used the WebClient before and I'm not sure if I should check the response from the server to know if the upload was successful or if I can let the file as uploaded if there is no exception. If I should check the response how can I do that? Parsing resposeHeaders property? Thanks in advance. The UploadFile method returns a byte[] that contains the response the remote server returned. Depending on how the server manages responses to upload requests (and error conditions (see note 1 below)) you will need to check that response. You can get the string response by converting it to a string,

Detecting whether a file is complete or partial in PHP

时间秒杀一切 提交于 2019-12-04 00:56:51
In this system, SFTP will be used to upload large video files to a specific directory on the server. I am writing a PHP script that will be used to copy completely uploaded files to another directory. My question is, what is a good way to tell if a file is completely uploaded or not? I considered taking note of the file size, sleeping the script for a few seconds, reading the size again, and comparing the two numbers. But this seems very kludgy. In theory, in case you are allowed to run system commands from PHP you can try to get the pids of your sftp server processes with pidof command and

createObjectURL is returning undefined in Chrome

我怕爱的太早我们不能终老 提交于 2019-12-04 00:28:31
问题 Trying to change video source file using createObjectDataURL. It is working fine with Firefox but not working in Chrome (version 12.0.742.122 m). code is not throwing any error but returns undefined for createObjectDataURL. I tried all the possibilities but it always returns undefined. <!DOCTYPE html> <html> <head> <title>Check CreateObjectURL</title> </head> <script type="text/javascript" language="javascript"> window.URL = window.URL || window.webkitURL; function ChangeProperty() { var v =

Uploading files using HTML file input on iphone

☆樱花仙子☆ 提交于 2019-12-03 22:59:55
I am creating a web form for uploading small movie clips to a HTTP server. However, while my HTML file input control gets shown on an ipod touch, the button is completely disabled and I cannot click it to upload files. What do I have to do to use the input control to upload files (e.g. movie clips or pictures) to my HTTP server. My page is XHTML MP 1.2 compliant. Gustav Meirinho IOS6 now allows it: http://agileleague.com/blog/hidden-gem-of-ios6-file-uploads-in-mobile-safari/ I tested and it works. Cheers! 来源: https://stackoverflow.com/questions/1577003/uploading-files-using-html-file-input-on