# change Storage directory for streams

**URL:** <https://community.wowza.com/t/change-storage-directory-for-streams/510>\
**Category:** Wowza Streaming Engine\
**Created:** [March 17, 2010, 8:15am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510 "2010-03-17T08:15:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [March 17, 2010, 8:15am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/1 "2010-03-17T08:15:08Z")

</div>

Hi,

I am trying to streams my flvs’ from my “c” drive instead of default storage directory .

I have override Play() method in my custom module like this :

```auto
 public void play(IClient client, RequestFunction function, AMFDataList params)
	{
		
		if (params.get(PARAM1).getType() == AMFData.DATA_TYPE_STRING)
		{
			String streamName = params.getString(PARAM1);
			params.set(PARAM1, new AMFDataItem("c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos/videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv"));
		}
		com.wowza.wms.module.ModuleCore.play(client, function, params);
	}

```

after making connection from client I get this errorr

```auto
  WARN server comment c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos/videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv open: java.io.FileNotFoundException: C:\Program Files\Wowza Media Systems\Wowza Media Server 2\applications\videoeditor\streams\_definst_\c___mnt_sdt-platfs1_images_forums2_FR_0_0_videos_videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv (The system cannot find the file specified)

```

Please help how can I Achieve this?

Also do I need to change Application.xml for this module

Thanks in advance

Mayur

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 17, 2010, 5:18pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/2 "2010-03-17T17:18:21Z")

</div>

Change Application.xml /StorageDir to the location you want to use.

```auto
<StorageDir>c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos</StorageDir>

```

Richard

---

<div class="post-metadata">

**Author:** ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)\
**Post date:** [March 18, 2010, 6:01am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/3 "2010-03-18T06:01:39Z")

</div>

You don’t want to do an application instance per connection. This is very inefficient. It would be better to change the relative path using the stream name.

You can use Streams/StorageDir setting in conf/[application]/Application.xml to change the root path to the storage location. You can rewrite the stream name if you override the play command. So for example if for each user you want to have his/her own storage location then you could create a directory structure like this:

/drive/mycontent

under which you have folders for each user:

/drive/mycontent/user1

/drive/mycontent/user2

You can set the Streams/StorageDir to **/drive/mycontent**. Then in the **play** command based on the parameters you send in you can rewrite the stream name to include the user id:

```auto
package com.wowza.wms.example.module;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
public class ModuleOverridePlayRemapStream extends ModuleBase {
	
	public void play(IClient client, RequestFunction function,
	        AMFDataList params) {
		getLogger().info("Overriding Play");
		
		String streamName = getParamString(params, PARAM1);
		
		params.set(PARAM1, userId+"/"+streamName);
		
		ModuleCore.play(client, function, params);
	}
}

```

I am not sure how you are passing around or discovering the userId but this is the most practical way to do it.

Charlie

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 11:38am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/4 "2010-03-18T11:38:46Z")

</div>

You can change StorageDir dynamically through IApplicationInstance method, but I think that will change it for all clients. That’s not what you are trying to do, is it?

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 1:25pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/5 "2010-03-18T13:25:51Z")

</div>

You can use subfolders, for example:

c:\content\userid

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 1:37pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/6 "2010-03-18T13:37:03Z")

</div>

Sorry, it would be client-side in the NetStream.play command.

```auto
netstream.play("userid/example.flv");

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 1:38pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/7 "2010-03-18T13:38:01Z")

</div>

Or more like:

> netstream.play(“1234/example.flv”);

Where 1234 is a userid.

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 1:47pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/8 "2010-03-18T13:47:41Z")

</div>

This is the dynamic method:

```auto
IApplicationInstance.setStreamStorageDir("c:\content\1234");

```

But I’m pretty sure it just changes it for everyone, per app instance. It would only work if your application is used by one client at a time… Unless each client connects to a different application instance:

```auto
rtmp://[wowza-address]/appName/1234

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 2:00pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/9 "2010-03-18T14:00:58Z")

</div>

You can do it onConnect. First connect like this in the client:

```auto
netconnection.connect("rtmp://[wowza-address]/appName/1234","1234")

```

Then do this in onConnect:

```auto
static public void onConnect(IClient client, RequestFunction function,
		AMFDataList params) 
{
String userID = getParamString(params, PARAM1);
client.getAppInstance().setStreamStorageDir("c:/content/" + userID);
}

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 2:33pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/10 "2010-03-18T14:33:46Z")

</div>

Charlie is also suggesting subfolders of the content location. He’s setting the location in play command server-side but essentially same as netstream.play(“1234/example.flv”)

I guess you are having problems with backslashes, or it just doesn’t work.

Subfolders per client is the way to do it.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 18, 2010, 3:03pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/11 "2010-03-18T15:03:03Z")

</div>

Try forward slashes “/” or escaping with two backslashes “\”

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 20, 2013, 9:27pm UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/12 "2013-09-20T21:27:15Z")

</div>

Yes, you can point to another local drive, or a mounted drive in you network.

In some cases a mounted drive may need or benefit from using [MediaCache addon](https://www.wowza.com/docs/how-to-scale-video-on-demand-streaming-with-media-cache%28scale-video-on-demand-streaming%29)

Richard

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 12:30am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/13 "2010-03-18T00:30:44Z")

</div>

This is what I did to test if it works external directory for stream storage.

But , I want to change this directory dynamically depending on the input parameter sent from flex client.

Please let me know if there is any way to do this ?

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 5:18am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/14 "2010-03-18T05:18:24Z")

</div>

right, thats not what we want to do, we have to have different storage directory for each client. it will be dependent on logged in user to application

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 5:33am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/15 "2010-03-18T05:33:41Z")

</div>

did not understand this ?

where should i specify this subfolder

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 5:38am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/16 "2010-03-18T05:38:15Z")

</div>

Yes it will be still inside /content of the wowza installation directory, and want it to be outside , may be on some server, or on s3

we are just trying from “c:” drive to test

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 5:52am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/17 "2010-03-18T05:52:48Z")

</div>

where shall I write ?

IApplicationInstance.setStreamStorageDir(“c:\content\1234”); ??

I can not write this on “onConnect”, as at that point, my client would not have called a server method to set the value

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 6:06am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/18 "2010-03-18T06:06:47Z")

</div>

it is giving me this error :

WARN server comment videos\_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv open: java.io.FileNotFoundException: C:\Documents and Settings\p7105669\Documents\workspace\sampleflvcropper\C\mnt\sdt-platfs1\images\forums2\FR\0\0\videos\videos\_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv (The system cannot find the path specified)

dont know from where its appending " C:\Documents and Settings\p7105669\Documents\workspace\sampleflvcropper"

Note : sampleflvcropper is the name of my project in workspace of wowzaIDE

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 6:11am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/19 "2010-03-18T06:11:23Z")

</div>

@ Charlie,

I did the same thing as you have suggested in very first attempt. (overriding the play method)

but i am getting this error

```auto
 WARN server comment c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos/videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv open: java.io.FileNotFoundException: C:\Program Files\Wowza Media Systems\Wowza Media Server 2\applications\videoeditor\streams\_definst_\c___mnt_sdt-platfs1_images_forums2_FR_0_0_videos_videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv (The system cannot find the file specified)

```

Please let me know , what i am doing worng

---

<div class="post-metadata">

**Author:** ![Mayur\_Bais](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@Mayur\_Bais](https://community.wowza.com/u/Mayur_Bais)\
**Post date:** [March 18, 2010, 6:24am UTC](https://community.wowza.com/t/change-storage-directory-for-streams/510/20 "2010-03-18T06:24:10Z")

</div>

any clue??

[Next page](https://community.wowza.com/t/change-storage-directory-for-streams/510.md?page=2)
