I have successfully uploaded a text file into a FS collection store. Now I want to modify the content of that text file or extract some information.
I can get the file object with:
var fileObj = myFSCollection.findOne({});
From what I have read, this is just a pointer to the file and not the file itself. How do I grab the text inside the text file so that I can modify it?
You can get the file itself with fileObj.url(). You cannot, however, update the file that CollectionFS has stored for you. You have to remove the original and insert a new one.
To download the file:
HTTP.get(fileObj.url(),function(err,result){
if ( !err ){
var content = result.content;
}
});
Related
When I upload a file in Drupal via the Drupal\file\Plugin\Field\FieldWidget\FileWidget I'd like to get access to the information of the original file, but not the copy.
For example I have a file at the location /home/rnsrk/foo.txt and I upload it via a form element "managed_file".
If I dump the fileUri in the FileWidget::process function with
$files = $element['#files'];
$file = array_shift($files);
dpm($file->getFileUri());
I get only the file info of the file already uploaded and copied to the temp dir: public://2022-11/foo_1.txt.
How do I get the information of the original file from /home/rnsrk/foo.txt?
I have an App that display nightclub description and image. Each club have about 4 related image.
In Firebase Storage i have created directory for each club and then stored their image inside.
so what i want to do is getting all the image from a club directory so i can display all the image in my app
i think a way of achieving this would be to get the DownloadUrl of each image.
i've tried this :
final StorageReference firebaseStorageRef = FirebaseStorage.instance.ref()
.child('profilePics/$clubID/SomeImage.jpg').getDownloadURL();
but since i don't know in advance the name of the image stored i can't use this
so any way of doing this ?
Future<void> listExample() async {
firebase_storage.ListResult result =
await firebase_storage.FirebaseStorage.instance.ref().listAll();
result.items.forEach((firebase_storage.Reference ref) {
print('Found file: $ref');
});
result.prefixes.forEach((firebase_storage.Reference ref) {
print('Found directory: $ref');
});
}
this code worked for me i got it from flutter fire website
here is the link to the docs
https://firebase.flutter.dev/docs/storage/usage
If you don't know the full path of an object in Cloud Storage, then you can't do anything with it using the mobile client SDKs. Typically, one gets the download URL at the time it was uploaded to the bucket, then writes that URL to a database so it can be queried for later.
A solution I came up with was, storing a .txt file which contained the name of each file, so first I read the text file, by line-breaking the file apart, and downloading my images in the same folder with the name of the file I got from the text file. This can work, if you can can store the names of all your files in a text file and then upload it!
Flow of the solution:
Store all the names of the files in the Firebase Storage's folder in a .txt file
write a method to get the text file and the break it line-by-line
write a method to get a download url, have this method call each time you get the name of your file from the .txt file.
use the image url as per your wish!
Any suggestions or corrections are welcomed!
https://github.com/FirebaseExtended/flutterfire/pull/232
Need to use package in pubspec.yaml like below :
firebase_storage:
git:
url: git://github.com/danysz/flutterfire.git
ref: master
path: packages/firebase_storage
Dart file
void getFirebaseImageFolder() {
final StorageReference storageRef =
FirebaseStorage.instance.ref().child('Gallery').child('Images');
storageRef.listAll().then((result) {
print("result is $result");
});
Original post by Mahesh Peri
I am trying to read a bulk of Adobe Indesign (indd) files and access its content through a script.
I want to check the name of drawing files present in the project and fetch that information in a flat file.
Can anybody help me with this as I am new to this technology?
If you are looking to read the bytes from the indd files, you cannot. The indd is a binary blob and no one knows what data is stored where.
If you are talking about getting list of placed files in the indd document, javascript can do that for you.
Step 1. Open the indd in indesign.
Step 2. the following script can return the path of each graphic in the doc
var grphx = app.activeDocument.allGraphics;
var i = 0;
for (i =0; i < grphx.length;++i)
{
alert(grphx[i].link.filePath);
}
I need to delete uploaded files from DAM Asset programmatically. Can we delete particular file node from DAM?
Path:-
/content/dam/nextgen/Ehub-POD/....
Inside Ehub-POD , I'm creating a folder and upload files. In jsp page I'll select particular file and need to delete the file from dam as well as from the jsp.
Let's Imagine we have the following image in dam:
/content/dam/nextgen/Ehub-POD/image1.jpg
To remove it use jcr Session:
session.removeItem("/content/dam/nextgen/Ehub-POD/image1.jpg")
if (session.hasPendingChanges()) {
session.save();
}
Image from dam will be removed, now you need to run query to find out where image was used and delete fileReference property:
Workspace workspace = session.getWorkspace();
QueryManager qm = workspace.getQueryManager();
Query query = qm.createQuery("/jcr:root/content/websitename/*[#fileReference='/content/dam/nextgen/Ehub-POD/image1.jpg']", Query.XPATH);
QueryResult queryResult = query.execute();
result = queryResult.getNodes();
while (result.hasNext()) {
Node node = result.nextNode();
node.getProperty("fileReference").remove();
}
or you can delete all info about image, received
node store info about cropping, fileReference and etc:
while (result.hasNext()) {
Node node = result.nextNode();
node.remove();
}
and don't forget to save your repository changes
if (session.hasPendingChanges()) {
session.save();
}
Another way to do it via CURL:
You can do a CURL DELETE request to the image path to remove it. Also, you can find all references to an image using CURL via following command:
http://localhost:4502/bin/wcm/references.json?path=/content/dam/nextgen/Ehub-POD/test-image.png
This will give you references of all the places where this image is used (except CSS or JS).
I'm deploying a small application with Adobe Air. My application will do batch upload from filepath which stored in a text file.
For example, in a text file name "list.txt", there is a string "C:\myfiles\IMG_0001.JPG". Now I want to upload this image file, keep tracking of upload progress :-<
I want to use FileReference to get the upload progress, but I don't know how to import from file's path. I also wonder how to use FileReference to upload this file without prompting a dialog for user to select file.
Thank you so much :)
Try the following. I have done a file upload without dialog box using following code.
var uploadURLs:URLRequest = new URLRequest("Your upload URL Here");
var params:URLVariables=new URLVariables();
params.title = "Hello";//URL Parameters if there is any
uploadURLs.data = params;
uploadURLs.method=URLRequestMethod.POST;
file = new File("Path to File");
file.addEventListener(ProgressEvent.PROGRESS , updateProgress);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, doneUpload);
file.addEventListener(IOErrorEvent.IO_ERROR,fileError);
file.upload(uploadURLs);
Hope this helps