I'm trying to download files which have no Normal [FILENAME].[EXTENSION] in URL, Using AsyncRead Downloading Method. There is no problem in Downloading process (It is Downloading file completely and save the file into Temp files). So i want to get Real Filename with Extension to save it to another place same as original file which is for downloading.
I can get file name while the URL is something like this:
Http://Host.com/Path/MyDoc.txt ( So i can get File name "MyDoc" and extension ".txt" easily because it specified at the URL )
But when downloading URL is something like this:
Http://Host.com/Path/download.php?File=9
I can not get the Real File name and Extension. Is there any way to get them on URLs like this?
Note: There is no problem in Downloading Process and I can download both of above files Completely. I Just want to get Filename and Extension.
Related
I've written a small FilePond example (excellent piece of work BTW) but there is one thing that I can't understand:
When I upload, e.g., "foo.JPG" or "foo.jpeg" it is saved as "foo.jpg" on the server.
I would like to keep the file extension, but don't know how to do it.
I've tried the FileRename-plugin but the files are still saved as .jpg.
I worked out a solution. If anyone is interested I can post complete code, but basically I stored the real filename (e.g., "foo.jpeg") in metadata and extracted it on the PHP server side, and then renamed the temporary file using that name instead.
In FilePond.create:
beforeAddFile: (fileItem) => new Promise(resolve => {
fileItem.setMetadata('true_filename', fileItem.filename);
resolve(true);
}),
I have images and I want to load them to my appplication.
my_app/lib/... - here my source files
my_app/assets/images/... - here my images
I need to get list of files in assets/images/ and after that show some of them (according to other logic)
I'm trying this
final dir = Directory("assets/images/");
print(dir.existsSync()); // <---- it also print: false
var files = dir.listSync().toList();
files.forEach((e) => list.add(MyImageItem(e.path)));
The problem is: I recieve exception
FileSystemException: Directory listing failed, path = 'assets/images/'
(OS Error: No such file or directory, errno = 2)
I've tried different ways: assets/images/, images/, images and so on
My pubspec.yaml
flutter:
assets:
- assets/images/
- assets/
When I create Image directly all is fine
new Image(image: AssetImage("assets/images/cat.png"))
I knew that previously (month ago) each resource has to be declared in pubspec.yaml directly, but now assets/images/ is ok.
I can load file by direct path. Why I can't access a directory? How to get list of files in directory to get them from my code?
When you add files to your assets, it means that you already know their paths.
Store all the images paths in a list and access them whenever you need.
For example if you have 3 images in
your_app/assets/images/image1.jpg
your_app/assets/images/image2.jpg
your_app/assets/images/image3.jpg
create a list and store all of them like:
List<String> imagePaths = ['assets/images/image1.jpg', 'assets/images/image2.jpg', 'assets/images/image3.jpg'];
and for example if you want to access your first image, use
AssetImage(imagePaths[0])
I keep a json file inside assets which records the file tree of assets folder.
When file list is needed, I just read from the json file.
Such json file can be easily generated by code.
However, this does not solve your problem directly when u have 5-10k images.
Only one json file might be too large to read.
Images should be grouped and recorded in separated json files.
I'm making a simple Lua script to download images. I get the URL of the image, and then this is my code to download it:
content = http.request(imageurl)
file = io.open("E:\\Users\\Me\\Documents\\Lua\\IMGDownload\\output.jpg", "w")
file:write(content)
print("Wrote content")
I get a 4KB file, however it isn't what I want it to be.
For reference, here is the image that I want to download:
RealImage http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/bd/bd05e23129b5d03ecb3f933589ff1477fbff4e92_full.jpg
This is what I actually get:
Can anyone pinpoint me as to the cause?
You probably just need to open the file with "wb" mode to get Windows to open the file in binary mode and not do line-ending conversion on you.
Try io.open("E:\\Users\\Me\\Documents\\Lua\\IMGDownload\\output.jpg", "wb").
I am using Net::FTP's getbinaryfile functionality to pull in a zip file with FTP. My system is not aware of the full file name, so I would simply like to search the folder for the zip file extension. Usually I would simply input the filename as *.zip. This does not seem to work.
ftp = Net::FTP.new(domain)
path = "#{Rails.root}/public/ftp/#{self.id}.zip"
ftp.getbinaryfile("*.zip", path)
I used the following code to return the zip file name in the FTP folder. Then using the same code as above, I was able to run getbinaryfile with the correct zip file name.
files = ftp.nlst("*.zip")
I use the following to get all zip files (I'm using SFTP but hopefully this will point you in the right direction)
Net::SFTP.start(domain, user, :password => 'pass') do |sftp|
sftp.dir.glob("/yourdirectory","*.zip").each do |file|
sftp.download!(file, "/local/spot")
end
end
My sprout core app name is myapp. My directory structure is myapp/apps/myapp/.
I have created a directory named jsons inside myapp/apps/myapp/, and placed a file called emp.json, I want to get this file through ajax using SC.Request.getUrl. I tried the following but didn't work. I want to know the url to reach out this file.
SC.Request.getUrl('/myapp/apps/myapp/resources/emp.json').notify(this, this.didFetchContacts)
.send();
SC.Request.getUrl('/myapp/resources/emp.json').notify(this, this.didFetchContacts)
.send();
Thanks
Ok, you will need to use static_url. So if emp.json is in your resources directory, you can call this:
SC.Request.getUrl(static_url('emp.json')).notify(this, this.didFetchContacts)
.send();
NOTE: This is not a javascript function. The compiler will replace this with the location of the file in the built app