How to upload Image using Meteror CollectionFS to server Folder - meteor

i'm new to meteor. And i found that there are lost of option available for image storing. And finally i decided to use this package
CollectionFS.
But in this package it stores file in collection. I do not want to store image in collection , i just want to upload it in my server folder.
Is it possible? How?
Thanks,

You are in luck, this is possible! Please refer to the documentation:
https://github.com/CollectionFS/Meteor-CollectionFS
In the Storage Adapter section is refers to cfs:filesystem. This allows you to save to the servers filesystem rather than a collection via GridFS. The Adapter and its documentation can be found here:
https://github.com/CollectionFS/Meteor-CollectionFS/tree/devel/packages/filesystem
The implementation is fairly straight forward with the documentation.
As it points out in the documentation, you can add something like this to your common.js file:
var Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});
This creates an FS.Collection called images which stores the images to a folded called uploads in your project and creates a collection to tie those uploads to. Structucing your project is a bit outside of the scope of your question, but you can get more information about that here:
http://docs.meteor.com/#/full/structuringyourapp

Related

Flutter Offline Images Before Uploading

So I'm trying to build an offline-first application with Firebase storage images but am running into an issue. I don't want the user to know when an image is being uploaded to Firebase or not and I want to show the image from the user's local storage immediately. Basically, I want the app to render the local storage image if the image isn't uploaded yet.
I currently use CachedNetworkImage but this requires that the image has been uploaded.
I could create the image URL before uploading it and somehow reference that URL with the local image but I'm not sure how to go about doing that. Any thoughts?
Edit:
I think I'm going to go with this approach: https://www.youtube.com/watch?v=vzrP93xNW8g
It's basically using Firestore track what's been uploaded or not.
Without code we're guessing of course, but making some assumptions here...
Assuming this means not all images will be in their local storage forever:
Could you simply check if an image exists in firebase and if it doesn't present the local image? That is, conditionally build a vanilla Image widget pulling from local storage or a CachedNetworkImage from a URL based on a variable. Perhaps you have a MyImage object with a URL property and pick which widget to build by checking if that is null in the build function.

Delete Firestore database from project

I have a firebase project and I added a Firestore database but I forgot to choose the right location. Since the location can not be modified after creating the database and the database is empty I would like to just delete it and create a new one with the correct location. Is this possible or do I need to create the whole project again?
Would appreciate help a lot.
Once a region is set for a project, it can't be changed. In the documentation it says:
Warning: Setting the location for one of the following services [Firestore, Storage, App Engine] also sets the location for the others. After you set your project's default GCP resource location, you cannot change it.
So, you will have to create a whole new project.

Simple/native file upload with Meteor

I need to upload an avatar to my app. But I want the shortest path to achieve this. Just a file input and a regular upload to my server side. Then I would just save whether or not the user has an avatar on MongoDB, move it to the avatar folder with the same name of the user's id.
But everything I see over there is quite complicated. All of them use third-party packages. But I guess Meteor provide it's own way with a little more configuration, doesn't it?
How can I do this task?
I suggest using CollectionFS plugin for meteor (link: https://github.com/CollectionFS/Meteor-CollectionFS ) - the documentation is pretty straightforward and clear.

Location of profile directory of XUL app

I'm creating a desktop app using Mozilla's XUL. I created an SQLite database, and stored some data in it. The database was created using:
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = FileUtils.getFile("ProfD", ["tickets.sqlite"]);
var dbConn = Services.storage.openDatabase(file);
I tested if the tables really exist using tableExists method, and I got true message. The database should be stored in the profile directory, which is by default located in a hidden folder (I use Fedora, by the way) in the home directory: ~/.mozilla/. Problem is I can't find my database there, stored as tickets.sqlite. Anyone?
If you got a file you can definitively retrieve its path using properties path, nativePath etc. - dump it onto console for example.
See https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile for more details about nsIFile.
Profile directory appears in app cache, for Linux it is in the home folder, and it's a hidden folder(not sure for WIN). Cache's name is defined in application.spec file, where you define Vendor name and App name, so cache folder is going to be .Vendor and inside it you will find App folder with details. That is the profile dir for Mozilla apps.

How to load WSDL from file

I am trying to save some bandwidth and include wsdl file in my flex/air application. Which url format should I use in order to load that file instead of the remote one.
I am using loadWSDL() method.
EDIT:
wsdl file needs to be part of the application. I know I can use file://some/path for local files, but don't know how to load file which is inside application itself.
If the file is local, just use the file URI scheme:
file://host/path/file.wsdl
If this doesn't work, check if the security sandbox features are blocking it.
In AIR apps, in order to access files in the application's temporary storage directory or the application's own directory, you need to use special app: or app-storage: URL schemes, though.
Like dirkgently said, you can always embed the file into the application, but as far as I know, you then won't be able to modify it afterwards in a persistent manner since it's not just a file in the filesystem. Probably the best option for you is to embed this file and if you later need to update it, have the app save an updated version into the File.applicationStorageDirectory (which you would then always check first before using the default embedded version.) Although I have no idea if using embedded XML files with the WebService classes is even possible.
See this article for info on how to embed external XML files into your app. This is how I've done it:
// note: common sense says that the mimeType should be "text/xml" here but
// it doesn't work -- this does, though. who knows why.
[Embed(source="File.xml", mimeType="application/octet-stream")]
private const _fileXMLClass:Class;
private var _fileXML:XML = XML(new _fileXMLClass());
wsdl file needs to be part of the application.
Have you tried embedding it inside the Flex/AIR project as a resource? Read this. For example, you can load static images shipped with your app by specifying the source as:
source="#Embed(source='relativeOrAbsolutePath')"
Uf, this was ugly, so I'm answering for the reference. Thanks for insights to hasseg and dirkgently
Here is the code.
First, declare the variables:
[Embed(source="/ws/wsdl/LoginService.wsdl",
mimeType="application/octet-stream")]
private const _fileXMLClass:Class;
private var _fileXML:XML = XML(new _fileXMLClass());
Then, loading wsdl:
var file : File = dir.resolvePath(name + ".xml");
var stream : FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes(getWsdl().toXMLString());
stream.close();
loadWSDL(file.url);
If someone have an idea to make this less ugly, please let me know.
EDIT: I just noticed edited answer, so instead of this code it was enough to use just:
loadWSDL('app:///path/to/my/file.wsdl');
I use below code in flash builder air mobile app and it works, may help some else. I get file contents from a web service using url loader and wirte it down to a xml file in document directory of my air app.
var url:URLRequest = new URLRequest(Globals.deviceSettings.endpoint);
loader.load(url);
loader.addEventListener(Event.COMPLETE, loaderComplete);
get the status of web service, if it is 200 then available and heads up.
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, ldrStatus);
and in the eventlistener
function loaderComplete(e:Event):void
{
var f:File= File.documentsDirectory.resolvePath("source/category.xml");
var _xml:XML = new XML(loader.data);
var fs:FileStream = new FileStream();
fs.open(f, FileMode.WRITE);
fs.writeUTFBytes(_xml.toXMLString());
fs.close();
popup.close(true);
var popup:MyPopupComponent = new MyPopupComponent();
popup.show("Successfully updated from the server",this);
popup.close();
}
you can use file.documentdirectory or applicaiton or your choice directory as per your need please keep in mind that some of the paths are read only for security. if you want to write back to those files you wont be able but just for reading purposes it is a good idea to place the files there.

Resources