# NGINX Upload Module - Temp Filenames to Proper Fil

**URL:** <https://www.ruby-forum.com/t/nginx-upload-module-temp-filenames-to-proper-fil/208343>\
**Category:** NGINX\
**Created:** [June 15, 2011, 5:47pm UTC](https://www.ruby-forum.com/t/nginx-upload-module-temp-filenames-to-proper-fil/208343 "2011-06-15T17:47:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 15, 2011, 5:47pm UTC](https://www.ruby-forum.com/t/nginx-upload-module-temp-filenames-to-proper-fil/208343/1 "2011-06-15T17:47:55Z")

</div>

Hi,

Am using NGINX Upload module to store files in my server’s disk. The  
filenames are in 10 digit numbers. When I tried to figure out things,  
the filename is allocated with 10 byte extra memory and a generated  
value of 10 digit becomes file name.

Here are my questions / clarifications:  
The files uploaded to my server are uploaded using a unique ID of 16  
digits (no duplicates). Though I can parse the HTTP header for the 16  
digit, I donno how to use that to store the file in that name.

1. I tried using freeing “file-\>name.data” and reallocate the variable  
to store the 16 digit filename. It failed.
2. I tried using a variable of type “ngx\_str\_t” to send the filename to  
the function “ngx\_open\_tempfile(ngx\_str\_t\_filename, 1,  
ulcf-\>store\_access);”. The CPU usage raised significantly and 20 out of  
30 files got uploaded.

Can anyone advice / help me in solving this problem?

- Reuben Joseph

Posted at Nginx Forum:

> **[NGINX Upload Module - Temp Filenames to Proper Fil](https://forum.nginx.org/read.php?2,207205,207205#msg-207205)**
>
> Hi, Am using NGINX Upload module to store files in my server's disk. The filenames are in 10 digit numbers. When I tried to figure out things, the filename is allocated with 10 byte extra memory and a generated value of 10 digit becomes file name....

---

<div class="post-metadata">

**Author:** ![kings.reuben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@kings.reuben](https://www.ruby-forum.com/u/kings.reuben)\
**Post date:** [June 16, 2011, 2:05am UTC](https://www.ruby-forum.com/t/nginx-upload-module-temp-filenames-to-proper-fil/208343/2 "2011-06-16T02:05:08Z")

</div>

On Wed, Jun 15, 2011 at 11:47:28AM -0400, kings.reuben wrote:

Hi there,

> Am using NGINX Upload module to store files in my server’s disk. The  
> filenames are in 10 digit numbers. When I tried to figure out things,  
> the filename is allocated with 10 byte extra memory and a generated  
> value of 10 digit becomes file name.
> 
> Here are my questions / clarifications:  
> The files uploaded to my server are uploaded using a unique ID of 16  
> digits (no duplicates). Though I can parse the HTTP header for the 16  
> digit, I donno how to use that to store the file in that name.

Using the upload module should make it a bit easier for you to write  
your own form-handling script than not using the upload module.

With a combination of upload\_set\_form\_field and upload\_pass\_form\_field  
directives, you’ll be able to get the 10 digit filename and the 16  
digit ID to your script. “rename” the one to the other in your script,  
and you are done.

> Can anyone advice / help me in solving this problem?

Don’t mess with the module code. proxy\_pass or fastcgi\_pass or something  
to your own form handler and do it there.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![kings.reuben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@kings.reuben](https://www.ruby-forum.com/u/kings.reuben)\
**Post date:** [June 16, 2011, 3:32pm UTC](https://www.ruby-forum.com/t/nginx-upload-module-temp-filenames-to-proper-fil/208343/3 "2011-06-16T15:32:39Z")

</div>

Hi,

Thanks for your suggestions. Name handling logic in Upload Module did  
the trick.

A few lines of uncommented code caused the problem of 20 out of 30  
completed file uploads.

- Reuben Joseph

Posted at Nginx Forum:

> **[Re: NGINX Upload Module - Temp Filenames to Proper Fil](https://forum.nginx.org/read.php?2,207205,207539#msg-207539)**
>
> Hi, Am using NGINX Upload module to store files in my server's disk. The filenames are in 10 digit numbers. When I tried to figure out things, the filename is allocated with 10 byte extra memory and a generated value of 10 digit becomes file name....
