public bool GetImageById(string id)
{
try
{
DirectoryInfo di = new DirectoryInfo(@"C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes");
foreach (var fi in di.GetFiles("*"+id+"*"))
{
Console.WriteLine(fi.Name);
}
return true;
}
catch
{
Console.WriteLine("El Archivo No existe");
return false;
}
}
this is my controller:
[Route("GetImageById/{id}")]
public bool GetImageById(string id)
{
ArticleModel articleModel = new ArticleModel();
var result = articleModel.GetImageById(id);
return result;
}
so basically this get the files from the path searching by file "Id".
And yes, this returns true.
How can i handle it to show the files on my dropzone? (mockfile)
I know there is an event, "addedfile", but i need some example.
It’s unclear what the use case for this is. Dropfile doesn’t access the server for a list of files (it just a JavaScript array). This might be useful if you are doing a custom thumbnail list, that is augmented by dropzone.
So when the user call "Edit view" i want to retrieve the stored files and show them on my Dropzone.
This approach is not going to work. In HTTP you get one file download. Even if the file were downloaded, JavaScript or Dropzone cannot select the file due to browser security. The user must select the file.
It is pretty easy to display links to a file and you have control over how the link is displayed.
You cannot use dropzones built in thumbnail list, you must write your own. You can use your custom thumbnail list instead of dropzones, so you have a common look. You probably will need a server thumbnail generator.
I know whats your point, but im telling you that i have a method returning this "C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png" on my Model.
wich is the same parameter used to create a Mockfile on the Browser when you hardcode the "call".
I just want to take this "C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png" from my Model List, put that on a variable on the front end and use it to be called/used by Dropzone javascript.
call "my variable"
please stop telling me that its not possible because i want to believe
I know whats your point, but im telling you that i have a method returning this "C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png" on my Model.
Can you share the code?
MVC_user
I just want to take this "C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png" from my Model List, put that on a variable on the front end and use it to be called/used by Dropzone javascript.
call "my variable"
Just serialize the model. Below is an ASP.NET core example.
public class FileModel
{
public string name { get; set; }
public int size { get; set; }
public string type { get; set; }
}
public IActionResult Index()
{
FileModel model = new FileModel()
{
name = "b0c88f23-818c-443c-91ce-3a8606a42c45_459.png",
size = 12345,
type = "image/png"
};
return View(model);
}
@model MvcDemo.Models.FileModel
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
@section scripts {
<script>
var path = "C:\\Sitios Webs Test\\appm_test.palermo.com.ar\\Imagenes\\";
var model = @Json.Serialize(Model);
console.log(model);
console.log(path + "@Model.name");
</script>
}
Member
36 Points
132 Posts
Do you have an example to mockfile and show files on Dropzone from the server?
Feb 14, 2020 07:10 PM|MVC_user|LINK
This is my Model:
this is my controller:
so basically this get the files from the path searching by file "Id".
And yes, this returns true.
How can i handle it to show the files on my dropzone? (mockfile)
I know there is an event, "addedfile", but i need some example.
Member
36 Points
132 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 14, 2020 08:13 PM|MVC_user|LINK
Changes...
Model:
Controller:
All-Star
58164 Points
15647 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 15, 2020 12:46 AM|bruce (sqlwork.com)|LINK
It’s unclear what the use case for this is. Dropfile doesn’t access the server for a list of files (it just a JavaScript array). This might be useful if you are doing a custom thumbnail list, that is augmented by dropzone.
Member
36 Points
132 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 17, 2020 12:46 PM|MVC_user|LINK
Basically, we have a view to edit an Article,
This view is a form, wich is fill with the data comming from the database for the related Article ( Name, Date expiration, etc ). And that works good.
On the server (folder path) i have stored some files related by GUID or Name to this Article.
So when the user call "Edit view" i want to retrieve the stored files and show them on my Dropzone.
A basic example will be usefull. Ill do the rest.
All-Star
53001 Points
23596 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 17, 2020 01:43 PM|mgebhard|LINK
This approach is not going to work. In HTTP you get one file download. Even if the file were downloaded, JavaScript or Dropzone cannot select the file due to browser security. The user must select the file.
It is pretty easy to display links to a file and you have control over how the link is displayed.
All-Star
58164 Points
15647 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 17, 2020 03:24 PM|bruce (sqlwork.com)|LINK
You cannot use dropzones built in thumbnail list, you must write your own. You can use your custom thumbnail list instead of dropzones, so you have a common look. You probably will need a server thumbnail generator.
Member
36 Points
132 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 05:08 PM|MVC_user|LINK
This way (hardcoded works) but ... must be a way to read values from the list on the Model:
Dropzone Javascript:
All-Star
53001 Points
23596 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 06:13 PM|mgebhard|LINK
You have a design bug. There's no reliable way for the web server to know where files are located on the client machines.
this.options.thumbnail.call(this, mockFile, "C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png");
It seem to work on your development machine because it is both the server and the client. The folder stricture is the same.
Member
36 Points
132 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 06:23 PM|MVC_user|LINK
I know, but the files are on my server. User will just choose an Article Id.
This file is on the server:
C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png
So that will be the same for all the users.
i see a code on my mind telling me something like:
Foreach File on my Model.List
(C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png)
Take name:
b0c88f23-818c-443c-91ce-3a8606a42c45_459.png as name,
Take .png as Type.
create mockfile with random size (1000 mb ?).
Then call C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png
First file is added, continue looping,
C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\Another__________FILE____________ON________MY__________LIST.png
Member
36 Points
132 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 06:30 PM|MVC_user|LINK
If i do something like that, get set for name variable, just to start,
how can i call it on the Dropzone Javascript?
All-Star
53001 Points
23596 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 06:48 PM|mgebhard|LINK
JavaScript runs in the browser not on the server.
Member
36 Points
132 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 06:57 PM|MVC_user|LINK
I know whats your point, but im telling you that i have a method returning this "C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png" on my Model.
wich is the same parameter used to create a Mockfile on the Browser when you hardcode the "call".
I just want to take this "C:\Sitios Webs Test\appm_test.palermo.com.ar\Imagenes\b0c88f23-818c-443c-91ce-3a8606a42c45_459.png" from my Model List, put that on a variable on the front end and use it to be called/used by Dropzone javascript.
call "my variable"
please stop telling me that its not possible because i want to believe
Member
36 Points
132 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 07:09 PM|MVC_user|LINK
F. this i will do it by my own:
First, modify this:
Then... i add this:
Then i change this:
now i just need to manipulate the filename and the type in another variables and this will work.
All-Star
53001 Points
23596 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 07:27 PM|mgebhard|LINK
Can you share the code?
Just serialize the model. Below is an ASP.NET core example.
@model MvcDemo.Models.FileModel @{ ViewData["Title"] = "Home Page"; } <div class="text-center"> <h1 class="display-4">Welcome</h1> <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> </div> @section scripts { <script> var path = "C:\\Sitios Webs Test\\appm_test.palermo.com.ar\\Imagenes\\"; var model = @Json.Serialize(Model); console.log(model); console.log(path + "@Model.name"); </script> }
All-Star
58164 Points
15647 Posts
Re: Do you have an example to mockfile and show files on Dropzone from the server?
Feb 18, 2020 09:09 PM|bruce (sqlwork.com)|LINK
see docs for server files:
https://gitlab.com/meno/dropzone/-/wikis/FAQ
init: function () { var mockFile = { name:"@(Model.ImageGuid).png", // display name size: @Model.ImageSize, //size of image type: 'image/png' }; this.displayExistingFile(mockFile, "@Url.Action("GetImageByName", new {id = Model.ImageGuid}));
then you need an action to return image: