Rectangle 27 25

There is no way to (at least as of now). Full request will be always buffered before nginx will start sending it to an upstream. To track uploaded files you may try upload progress module.

Update: in nginx 1.7.11 the proxy_request_buffering directive is available, which allows to disable buffering of a request body. It should be used with care though, see docs.

upload progress module is great, but we're using several servers for uploads processing behind load balancing, so there is always chance that request for progress update will be routed to another server(even with some load balance tricks).

nginx files upload streaming with proxy_pass - Stack Overflow

file-upload nginx
Rectangle 27 25

There is no way to (at least as of now). Full request will be always buffered before nginx will start sending it to an upstream. To track uploaded files you may try upload progress module.

Update: in nginx 1.7.11 the proxy_request_buffering directive is available, which allows to disable buffering of a request body. It should be used with care though, see docs.

upload progress module is great, but we're using several servers for uploads processing behind load balancing, so there is always chance that request for progress update will be routed to another server(even with some load balance tricks).

nginx files upload streaming with proxy_pass - Stack Overflow

file-upload nginx
Rectangle 27 3

Yes, you can call it API to track the end of a multiple upload process:

var $fileInput = $('#fileupload');

$fileInput.on('fileuploaddone', function(e, data) {
    var activeUploads = $fileInput.fileupload('active');
    /*
     * activeUploads starts from the max number of files you are uploading to 1 when the last file has been uploaded.
     * All you have to do is doing a test on it value.
     */
    if(activeUploads == 1) {
        console.info("All uploads done");
        // Your stuff here
    }
}

jquery - Finish of Multiple file upload - Stack Overflow

jquery file-upload blueimp
Rectangle 27 9

Your issue is that in the new branch you are not tracking upload/file.txt but you are tracking it in your master branch. So when you switch to your new branch, your version, from master, will overwrite the untracked file.

-f

It works, I'm able to change branches. But it gives a list of errors "unable to unlink" for each file in the upload folder. Git status says "nothing to commit" in both branches. Is possible to avoid this errors or should I live with it? :)

Why do I receive the error "Untracked working tree file" when switchin...

git
Rectangle 27 64

.gitignore
upload/*

You can do this:

$ touch upload/.placeholder
$ git add -f upload/.placeholder

If you forget the -f you'll see:

git status

Obviously you can then do:

$ touch upload/images/.placeholder
$ git add -f upload/images/.placeholder

A common convention for a placeholder is a gitignore file.

@Jefromi Indeed, as my comments to Abizern, had never considered using the .gitignore file as the placeholder.

Git doesn't track directories, it tracks files sounds funny when they teach you that everything is a file in UNIX, even a directory is a file

directory - How to track directories but not their files with Git? - S...

git directory gitignore
Rectangle 27 1

Like matt has said, I recommend you always leave it selected as well. I have had troubles uploading the app, even though I know I have not moved or renamed the file. Also an extra benefit of leaving it enabled is that it makes it easier to share the project with others without having to track down the files not in the project folder.

I can see two cases why leaving it off might be convenient:

  • You have multiple projects which share the same file and want to reduce space,
  • You desperately need to save the space on your computer, in which case I would buy extra storage for your computer.

Edit: Even though you copied the file in, XCode treats it as a link to the file, this is why you are seeing this message.

ios - When to check "Copy items if needed" for embedded binaries? - St...

ios xcode
Rectangle 27 19

Here's my final working code. My web service needed one file (POST parameter name was "file") & a string value (POST parameter name was "userid").

/// <summary>
/// Occurs when upload backup application bar button is clicked. Author : Farhan Ghumra
 /// </summary>
private async void btnUploadBackup_Click(object sender, EventArgs e)
{
    var dbFile = await ApplicationData.Current.LocalFolder.GetFileAsync(Util.DBNAME);
    var fileBytes = await GetBytesAsync(dbFile);
    var Params = new Dictionary<string, string> { { "userid", "9" } };
    UploadFilesToServer(new Uri(Util.UPLOAD_BACKUP), Params, Path.GetFileName(dbFile.Path), "application/octet-stream", fileBytes);
}

/// <summary>
/// Creates HTTP POST request & uploads database to server. Author : Farhan Ghumra
/// </summary>
private void UploadFilesToServer(Uri uri, Dictionary<string, string> data, string fileName, string fileContentType, byte[] fileData)
{
    string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
    HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
    httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
    httpWebRequest.Method = "POST";
    httpWebRequest.BeginGetRequestStream((result) =>
    {
        try
        {
            HttpWebRequest request = (HttpWebRequest)result.AsyncState;
            using (Stream requestStream = request.EndGetRequestStream(result))
            {
                WriteMultipartForm(requestStream, boundary, data, fileName, fileContentType, fileData);
            }
            request.BeginGetResponse(a =>
            {
                try
                {
                    var response = request.EndGetResponse(a);
                    var responseStream = response.GetResponseStream();
                    using (var sr = new StreamReader(responseStream))
                    {
                        using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
                        {
                            string responseString = streamReader.ReadToEnd();
                            //responseString is depend upon your web service.
                            if (responseString == "Success")
                            {
                                MessageBox.Show("Backup stored successfully on server.");
                            }
                            else
                            {
                                MessageBox.Show("Error occurred while uploading backup on server.");
                            } 
                        }
                    }
                }
                catch (Exception)
                {

                }
            }, null);
        }
        catch (Exception)
        {

        }
    }, httpWebRequest);
}

/// <summary>
/// Writes multi part HTTP POST request. Author : Farhan Ghumra
/// </summary>
private void WriteMultipartForm(Stream s, string boundary, Dictionary<string, string> data, string fileName, string fileContentType, byte[] fileData)
{
    /// The first boundary
    byte[] boundarybytes = Encoding.UTF8.GetBytes("--" + boundary + "\r\n");
    /// the last boundary.
    byte[] trailer = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n");
    /// the form data, properly formatted
    string formdataTemplate = "Content-Dis-data; name=\"{0}\"\r\n\r\n{1}";
    /// the form-data file upload, properly formatted
    string fileheaderTemplate = "Content-Dis-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type: {2}\r\n\r\n";

    /// Added to track if we need a CRLF or not.
    bool bNeedsCRLF = false;

    if (data != null)
    {
        foreach (string key in data.Keys)
        {
            /// if we need to drop a CRLF, do that.
            if (bNeedsCRLF)
                WriteToStream(s, "\r\n");

            /// Write the boundary.
            WriteToStream(s, boundarybytes);

            /// Write the key.
            WriteToStream(s, string.Format(formdataTemplate, key, data[key]));
            bNeedsCRLF = true;
        }
    }

    /// If we don't have keys, we don't need a crlf.
    if (bNeedsCRLF)
        WriteToStream(s, "\r\n");

    WriteToStream(s, boundarybytes);
    WriteToStream(s, string.Format(fileheaderTemplate, "file", fileName, fileContentType));
    /// Write the file data to the stream.
    WriteToStream(s, fileData);
    WriteToStream(s, trailer);
}

/// <summary>
/// Writes string to stream. Author : Farhan Ghumra
/// </summary>
private void WriteToStream(Stream s, string txt)
{
    byte[] bytes = Encoding.UTF8.GetBytes(txt);
    s.Write(bytes, 0, bytes.Length);
}

/// <summary>
/// Writes byte array to stream. Author : Farhan Ghumra
/// </summary>
private void WriteToStream(Stream s, byte[] bytes)
{
    s.Write(bytes, 0, bytes.Length);
}

/// <summary>
/// Returns byte array from StorageFile. Author : Farhan Ghumra
/// </summary>
private async Task<byte[]> GetBytesAsync(StorageFile file)
{
    byte[] fileBytes = null;
    using (var stream = await file.OpenReadAsync())
    {
        fileBytes = new byte[stream.Size];
        using (var reader = new DataReader(stream))
        {
            await reader.LoadAsync((uint)stream.Size);
            reader.ReadBytes(fileBytes);
        }
    }

    return fileBytes;
}

c# - How to upload file to server with HTTP POST multipart/form-data -...

c# php post windows-phone-8 multipartform-data
Rectangle 27 1

Thanks, Kerni I was able to debug the issue by tracking down the crash report via iPhone Configuration Utility . I Selected the Devices I was debugging and opened the Console Tab on the iPhone Configuration Utility hitting clear and check it out. I Saved the log after getting the app to crash again and found that I had been using In-App Audio when I didn't add it to the App ID when I was creating my provisioning profile. This was the only issue. After I went threw all of the steps again the IPA Uploaded just fine. The app installed like one would imagine!

iphone - iOS App Won't start on Testflight Ad Hoc Distribution - Stack...

ios iphone xcode testflight ad-hoc-distribution
Rectangle 27 1

Thanks, Kerni I was able to debug the issue by tracking down the crash report via iPhone Configuration Utility . I Selected the Devices I was debugging and opened the Console Tab on the iPhone Configuration Utility hitting clear and check it out. I Saved the log after getting the app to crash again and found that I had been using In-App Audio when I didn't add it to the App ID when I was creating my provisioning profile. This was the only issue. After I went threw all of the steps again the IPA Uploaded just fine. The app installed like one would imagine!

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

iphone - iOS App Won't start on Testflight Ad Hoc Distribution - Stack...

ios iphone xcode testflight ad-hoc-distribution
Rectangle 27 0

You need to write custome xhr function to achieve tracking of progress of file uploads

$.ajax({
                url: "resource/php/upload.php",
                type: "POST",
                data: formdata,
                dataType : 'json',
                processData: false,
                contentType: false,
               //@custome xhr
                xhr: function() {  // custom xhr
                   myXhr = $.ajaxSettings.xhr();
                   if(myXhr.upload){ // check if upload property exists
                       myXhr.upload.addEventListener('progress',progressHandlingFunction,  false); // for handling the progress of the upload
                   }
                   return myXhr;
                },
               //@custome xhr end
                success: function(data) {
                             $('#ajax-loader').hide();
                            //appends the currently uploaded images in  a div
                             }
                });

See the comment @custome xhr in above code And add a function to update progress bar

function updateProgress(evt) {
    console.log('updateProgress');
    if (evt.lengthComputable) {
            var percentComplete = evt.loaded / evt.total;
            console.log(percentComplete);
    } else {
            // Unable to compute progress information since the total size is unknown
            console.log('unable to complete');
    }
}

How to upload file using jquery ajax php - Stack Overflow

php jquery ajax forms file-upload
Rectangle 27 0

Ok, figured it out. The HttpWebRequest object, if you set the ContentLength property, will directly connect it's ResponseStream to the network socket when you call GetRequestStream(). This then allows you to track your progress by writing directly to this stream.

I tried your example but upload only start after the whole file was processed. Any idea why? Are you sure it did work correctly for you?

Thank you! I had the same issue and it was driving me crazy!

Same for me. Has anyone found a working solution?

.net - C# HttpWebRequest Form Post with Progress Tracking (for uploadi...

c# .net winforms post httpwebrequest
Rectangle 27 0

I read that blog post mentioned by CorneM but I wasn't too keen on the implementation..

Instead I subclassed FileStream so that it raised events every so often that it was read from, and provided my subclassed filestream to the UploadFromStream method on the azure storage client in the SDK. Much cleaner, IMHO

public delegate void PositionChanged(long position);

public class ProgressTrackingFileStream: FileStream
{
    public int AnnounceEveryBytes { get; set; }
    private long _lastPosition = 0;


    public event PositionChanged StreamPositionUpdated;

    // implementing other methods that the storage client may call, like ReadByte or Begin/EndRead is left as an exercise for the reader

    public override int Read(byte[] buffer, int offset, int count)
    {
        int i = base.Read(buffer, offset, count);

        MaybeAnnounce();

        return i;
    }

    private void MaybeAnnounce()
    {
        if (StreamPositionUpdated != null && (base.Position - _lastPosition) > AnnounceEveryBytes)
        {
            _lastPosition = base.Position;
            StreamPositionUpdated(_lastPosition);
        }
    }

    public ProgressTrackingFileStream(string path, FileMode fileMode) : base(path, fileMode) 
    {
        AnnounceEveryBytes = 32768;
    }

}
CloudBlockBlob blockBlob = _container.GetBlockBlobReference(blobPath);

        using (ProgressTrackingFileStream ptfs = new ProgressTrackingFileStream(file.FullName, FileMode.Open))
        {
            ptfs.StreamPositionUpdated += ptfs_StreamPositionUpdated;

            blockBlob.UploadFromStream(ptfs);
        }

This is not accurate, you just track reading the file into memory not uploading it to Azure which takes much longer. I'm looking for a solution myself, I think the accurate approach should be around block level.

c# - Track the upload progress while uploading file to azure blob - St...

c# asp.net file-upload video-streaming azure-storage-blobs
Rectangle 27 0

We just released a new Python API wrapper. You can get it on PyPi or from our Github account. To upload a track, you'll want to first get an access token using one of the supported OAuth2 auth flows. You can read about that in the README file. Let me know if you want me to elaborate on auth and I can edit my answer.

To get an access token, first register your application on soundcloud.com. You will need to provide a URI that users will be directed to after authorizing your application and you will be given a client id and client secret. Once you have those credentials, pass them to the Client constructor:

import soundcloud
client = soundcloud.Client(client_id=YOUR_CLIENT_ID,
                           client_secret=YOUR_CLIENT_SECRET,
                           redirect_uri="http://your/redirect/uri")

You'll then be able to redirect the user to the authorization URL in order to authorize your app. The user will be sent to soundcloud.com to log in (if they do not have an active session) and approve access for your app. Depending on the framework you're using (e.g. Django, Flask, etc) it could look something like this:

return redirect(client.authorize_url)

After approving access for your app, the user will be redirected to the redirect uri you specified when registering your app and in the constructor. The URL will have a query string that includes a 'code' parameter which you can then use to obtain an access token. Again, depending on the framework you're using, this could look like this:

code = request.params.get('code')
token = client.exchange_token(code)
print token.access_token  # don't actually print it, just showing how you would access it

You should probably store the access token (i.e. in some kind of data store like MySQL or Redis) so you can use it whenever that user wants to access SoundCloud in the future.

Once you've got an access token, uploading a track should be pretty simple. Once you've got your audio file, just send a POST request to the tracks resource. Here's an example:

import soundcloud

client = soundcloud.Client(access_token='YOUR_ACCESS_TOKEN')
track = client.post('/tracks', track={
    'title': 'The title you want to give your track',
    'sharing': 'private',  # make this 'public' if you want
    'asset_data': open('yourtrack.mp4', 'rb')
})

You'll get back a track resource, which you can then use to get the Soundcloud URL:

print track.permalink_url

Hope that helps! Let me know if you have any questions.

Thanks a lot @Paul! It was really helpful! And yes, I would like to hear more on auth and about how to get the access token.. It would help me a lot..

Paul, would it be possible to post this to your own account, i.e. not doing it on behalf of another user, but just for your own user. How would the authentication differ?

Hey Andres, you could use the User Credentials Flow in that case. developers.soundcloud.com/docs/api/

How to upload files to Soundcloud using Python? - Stack Overflow

python soundcloud
Rectangle 27 0

Try to use jQuery Form plugin, it supports ajax file uploads as well so you don't need to implement this by yourself. It also allows to track upload progress.

ajax - Multiple files upload in grails - Stack Overflow

ajax grails file-upload
Rectangle 27 0

Something that I just discovered is that in IE, if the upload area is hidden when the swf file is initialized, the uploadify onOpen() event never fires and the file upload never starts. So, make sure that the div that your tracks are uploaded in aren't being hidden with css to be displayed later at the moment the uploadify function starts or don't fire off the function until the asset area div is shown.

jquery - Uploadify causing error in IE 7/8 - Stack Overflow

jquery internet-explorer uploadify
Rectangle 27 0

There was not much detail about what this app is, or how it works so this response is vague but I believe you can do something like this to track your upload progress.

If this really is a Java Client App (i.e. Not HTML/JavaScript but a java program) and you really are having it upload a file as a stream then you should be able to track your upload progress by counting the bytes in the array being transmitted in the stream buffer and comparing that to the total byte count from the file object.

When you get the file get its size.

Integer totalFile = file.getTotalSpace();

Where ever you are transmitting as a stream you are presumably adding bytes to a output buffer of some kind

byte[] bytesFromSomeFileReader =  [whatEverYouAreUsingToReadTheFile];

    ByteArrayOutputStream byteStreamToServer = new ByteArrayOutputStream();
    Integer bytesTransmitted = 0;

    for (byte fileByte : bytesFromSomeFileReader) {
        byteStreamToServer.write(fileByte);
            //
            //  Update your progress bar every killo-byte sent.
            //
        bytesTransmitted++;
        if( (bytesTransmitted % 1000) = 0) {
            someMethodToUpdateProgressBar();
        }
    }

Sorry but this doesn't help. In principle this solution is sound but as I stated in the OP the stream seems to be completely read before the upload commences. So the progress bar would whiz to 100% and then sit there for however long the upload took.

??? How is it read BEFORE the upload? That is not possible. As stated no details were given has to what is being done or how. You would have to give actual details provide a more detailed answer.

Also if we are talking about the client here how is the stream read? It should be written from the client.

The stream I'm referring to is the file input stream of the local file that is being uploaded to the remote server. I can't provide any details now as this was a project I worked on 2 years ago! As I said in the OP I believed that the content to be uploaded was being buffered, so the streams were completely read/written before any network traffic commenced. So I could not use these streams to implement a progress bar.

spring - File upload progress bar using RestTemplate.postForLocation -...

spring upload progress-bar multipart resttemplate
Rectangle 27 0

It's true the interface of AFHTTPSessionManager doesn't provide a method to track the upload progress. But the AFURLSessionManager does.

AFURLSessionManager
AFHTTPSessionManager
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer]  multipartFormRequestWithMethod:@"POST" URLString:kUploadImageURL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    [formData appendPartWithFileData:UIImageJPEGRepresentation(image, 0.5) name:@"uploadFile" fileName:@"image" mimeType:@"image/jpeg"];
} error:nil];

NSProgress *progress;
NSURLSessionDataTask *uploadTask = [[AFHTTPSessionManager sharedManager] uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (!error) {
        //handle upload success
    } else {
        //handle upload failure
    }
}];
[uploadTask resume];
[progress addObserver:self forKeyPath:@"fractionCompleted" options:NSKeyValueObservingOptionNew context:NULL];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    if ([keyPath isEqualToString:@"fractionCompleted"] && [object isKindOfClass:[NSProgress class]]) {
        NSProgress *progress = (NSProgress *)object;
        //progress.fractionCompleted tells you the percent in CGFloat
    }
}

use KVO to track progress means self need to be alive during observation. The more elegant way is AFURLSessionManager's method setTaskDidSendBodyDataBlock, like this:

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager setTaskDidSendBodyDataBlock:^(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
    //during the progress
}];

NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer]  multipartFormRequestWithMethod:@"POST" URLString:kUploadImageURL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    [formData appendPartWithFileData:UIImageJPEGRepresentation(image, 0.5) name:@"uploadFile" fileName:@"image" mimeType:@"image/jpeg"];
} error:nil];

NSURLSessionDataTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (!error) {
        //handle upload success
    } else {
        //handle upload failure
    }
}];
[uploadTask resume];

setTaskDidSendBodyDataBlock is called when all the data has been sent. It is not much of a gradual progress. how to get step by step percentage of progress? I am using dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:

The strange thing is that when it has finished uploading it is called multiple times. It might be some threading related problem

I missed NSURLSessionConfiguration with AFHTTPSessionManager. It got called gradually. Althought in dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: uploadProgress is still being called after it is finished.

ios - AFNetworking 2.0 track file upload progress - Stack Overflow

ios afnetworking-2
Rectangle 27 0

I haven't found an API to track progress. One way I have implemented the progress bar is by uploading the blob as smaller chunks to azure storage. As each chunk uploads successfully, you can variations in the progress bar based on the number of chunks.

c# - Track the upload progress while uploading file to azure blob - St...

c# asp.net file-upload video-streaming azure-storage-blobs
Rectangle 27 0

By Default, you should be able to upload a file upto 4MB and MaxRequestLength is in Kilo Bytes. So, Default value is 4096KB. If you try to upload the file with size over 4MB, you will get an error. So, Increase that to some 25Mb or a large number. Then you should be able to track file size in your code.

<httpRuntime maxRequestLength="2097151" executionTimeout="3600"/>

asp.net - uploading attachment - restricting file size - IE cannot dis...

asp.net file-upload
Rectangle 27 0

If you are using XHR2 to upload files cross-origin, AND you want to track upload progress, your server will need to handle preflight (OPTIONS) requests, which the browser will send before it sends the underlying upload POST request. This is, of course, in addition to the support this server must have for non-preflighted CORS requests.

XHR2's upload progress specifically triggers a preflight, even if nothing else about the upload POST request requires the cross-origin request to be preflighted. I stumbled into this a while back myself.

If you have no control over the server and it does not handle OPTIONS/preflight requests, you will not be able to make use of upload progress events.

javascript - How to send a file on cross-domain with XMLHttpRequest? -...

javascript ajax xmlhttprequest cross-domain